Reputation: 121
I have an issue please. Each time I set up a react project, either with create react app or using webpack or whatever, I just get stuck at NPM start. It always returns an error. Please I am fed up with this. Can someone tell me what the issue might be? But what bugs me the most is, I use Next.js, and each time I run Npm start on Nextjs dev server, it works fine... Please what might be the issue with my react app?
Here's the error:
C:\Users\Kelly\Desktop\My webpack react app>npm start
> [email protected] start C:\Users\Kelly\Desktop\My webpack react app
> webpack-dev-server --mode development --open --hot
i 「wds」: Project is running at http://localhost:8080/
i 「wds」: webpack output is served from /
i 「wds」: Content not from webpack is served from C:\Users\Kelly\Desktop\My webpack react app
events.js:298
throw er; // Unhandled 'error' event
^
Error: spawn cmd ENOENT
←[90m at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)←[39m
←[90m at onErrorNT (internal/child_process.js:467:16)←[39m
←[90m at processTicksAndRejections (internal/process/task_queues.js:84:21)←[39m
Emitted 'error' event on ChildProcess instance at:
←[90m at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)←[39m
←[90m at onErrorNT (internal/child_process.js:467:16)←[39m
←[90m at processTicksAndRejections (internal/process/task_queues.js:84:21)←[39m {
errno: ←[33m-4058←[39m,
code: ←[32m'ENOENT'←[39m,
syscall: ←[32m'spawn cmd'←[39m,
path: ←[32m'cmd'←[39m,
spawnargs: [ ←[32m'/c'←[39m, ←[32m'start'←[39m, ←[32m'""'←[39m, ←[32m'/b'←[39m, ←[32m'http://localhost:8080/'←[39m ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `webpack-dev-server --mode development --open --hot`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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\Kelly\AppData\Roaming\npm-cache\_logs\2020-04-07T07_23_56_199Z-debug.log
Upvotes: 1
Views: 2859
Reputation: 308
i was also facing this same issue . after spending some time i just simply install the node.js most user version . and now issue is fixed . before it was installed latest version of node js.
Upvotes: 0
Reputation: 11
It is because you have added insufficient paths in your Environmental variables.
First you can do is close the vs code,
Go to the properties of My Pc,
Click on Advanced Settings,
click on Environmental Variables,
from there you can add path clicking the path variables in the table. Add a new line to the path and copy paste the path of your system 32,
C:\Windows\System32
hope this solution works in your case
(I've been trying to fix this problem for so long this is the only solution i found that worked)
Upvotes: 1
Reputation: 121
About this question I posted here earlier, I finally found a solution to it. And I hope it would help someone. I think it's probably due to my computer's OS, the fact is I still don't know the reason my NPM start didn't work, but I found out that it was because my "react-scripts" version, which can be found in your package.json, was 3.4.1, which I think is the latest. I tried downloading the lower versions up till 2.1.8, then it worked at version 2.1.8. Though that version is way outdated, and it's probably not recommended that anyone use it, but if you still are stuck like I was, then you should try it, until you find a better solution.
Just write these commands:
npx create-react-app my-app
cd my-app
npm i --save-dev [email protected]
npm start
That should work and help you get your app on board. I hope this helps someone.
Upvotes: 1
Reputation: 36
Have you restored the npm packages?
In the terminal, run:
npm install
Upvotes: 0