1

I'm using node(12.16.2) and npm(6.14.4) and create-react-app(3.4.1). After creating an app with create-react-app {app name} and going to its directory, I run it with npm start I see error below. I think the problem is with my npm not spawn. Here is the error:

> tesssssst@0.1.0 start C:\Users\Yasaman\Desktop\tesssssst
> react-scripts start

i 「wds」: Project is running at http://0.0.0.0:3000/
i 「wds」: webpack output is served from
i 「wds」: Content not from webpack is served from C:\Users\Yasaman\Desktop\tesssssst\public
i 「wds」: 404s will fallback to /
Starting the development server...

events.js:287
      throw er; // Unhandled 'error' event
      ^

Error: spawn cmd ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
    at onErrorNT (internal/child_process.js:469:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)
    at onErrorNT (internal/child_process.js:469:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn cmd',
  path: 'cmd',
  spawnargs: [ '/s', '/c', 'start', '""', '/b', '"http://localhost:3000"' ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! tesssssst@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the tesssssst@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Yasaman\AppData\Roaming\npm-cache\_logs\2020-04-26T20_33_07_370Z-debug.log

How can I fix this problem?

Yasaman.Mansouri
  • 550
  • 1
  • 3
  • 13
  • Does this answer your question? [How do I debug "Error: spawn ENOENT" on node.js?](https://stackoverflow.com/questions/27688804/how-do-i-debug-error-spawn-enoent-on-node-js) – Wyck Apr 26 '20 at 21:48
  • 1
    Local `create-react-app` doesn't seem to work fine with Windows. Try to remove it `npm uninstall -g create-react-app` and use [npx](https://reactjs.org/docs/create-a-new-react-app.html#create-react-app) instead `npx create-react-app ` – awran5 Apr 26 '20 at 21:54
  • 1
    Try what @awran5 wrote in his comment. Also *CRA* by default uses *Yarn* to craft the project instead of *NPM* so you should try `yarn start`; make sure which package manager is used by *CRA* while it's crafting the project. Lastly (*though it is not the cause of the problem*), try using *Powershell Core* instead of *CMD* and *Windows Terminal*; you'll get much better results and workflow. – Christos Lytras Apr 26 '20 at 22:00
  • @ChristosLytras I guess *Powershell* also has the same issue. The only workaround I know is to use [Git](https://git-scm.com/download/win) bash shell but it requires some steps to get it to work. – awran5 Apr 26 '20 at 22:11
  • 1
    @awran5 I'm using *Powershell Core* for many years with *React*, *CRA*, *React Native* and many other *Node* and *Python* development stacks with no issues at all. – Christos Lytras Apr 26 '20 at 22:14
  • @awran5 I tried what you say before but it didn't work. – Yasaman.Mansouri Apr 26 '20 at 22:40
  • @Christos Lytras you mean I should use yarn instead of npm? – Yasaman.Mansouri Apr 26 '20 at 22:43
  • 2
    @Yasaman.Mansouri, Set your Windows environment variable, add %SystemRoot%\system32 to your PATH, if it right, tells me to post it as an answer. – AmerllicA Apr 26 '20 at 23:02
  • @ChristosLytras You know better, I had these kind of issues a while ago so I moved to Git bash shell and never back. – awran5 Apr 26 '20 at 23:03
  • 1
    @Yasaman.Mansouri as **AmerllicA** said, try adding `C:\Windows\System32` to the PATH in environment variables as mentioned [here](https://stackoverflow.com/a/60861528/8254484) Try these [methods](https://www.computerhope.com/issues/ch000549.htm) – awran5 Apr 26 '20 at 23:07
  • 1
    @Yasaman.Mansouri, Does [my answer](https://stackoverflow.com/a/61449354/6877799) work? – AmerllicA Apr 27 '20 at 06:30
  • I leave an upvote. I hope it motivates you to keep going on Stack Overflow. – AmerllicA Apr 27 '20 at 14:07

1 Answers1

3

For ridiculous issues, seek to find ridiculous solutions. It happens just because of your environment settings. You should set your Windows environment variable and add %SystemRoot%\system32 to your PATH. In the following, you can see the steps of doing PATH:

  1. On the Windows desktop, right-click My Computer.

  2. In the pop-up menu, click Properties.

  3. In the System Properties window, click the Advanced tab, and then click Environment Variables.

  4. In the System Variables window, highlight Path and click Edit.

  5. In the Edit System Variables window, insert the cursor at the end of the Variable Value field.

  6. If the last character is not a semi-colon (;), add one.

  7. After the final semi-colon, type the full path to the file you want to find.

    %SystemRoot%\system32
    
  8. Click OK in each open window

  9. Restart System

AmerllicA
  • 29,059
  • 15
  • 130
  • 154