error in running an react js application in windows - node.js

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?

For ridiculous issues, seek to find ridiculous solutions, it happens just because of your environment settings, you should set your Windows environment variable, _add %SystemRoot%\system32 to your PATH, if it right, tell me to post it as an answer:
On the Windows desktop, right-click My Computer.
In the pop-up menu, click Properties.
In the System Properties window, click the Advanced tab, and then click Environment Variables.
In the System Variables window, highlight Path, and click Edit.
In the Edit System Variables window, insert the cursor at the end of the Variable value field.
If the last character is not a semi-colon (;), add one.
After the final semi-colon, type the full path to the file you want to find.
%SystemRoot%\system32
Click OK in each open window
Restart System

Related

NodeJS Express app crashes after some time

NodeJS Express App crashes after some time.
I start using npm start having start script as
start: "node app.js"
Error
at Socket.emit (events.js:400:28)
at emitErrorNT (internal/streams/destroy.js:106:8)
at emitErrorCloseNT (internal/streams/destroy.js:74:3)
at processTicksAndRejections (internal/process/task_queues.js:82:21) {
errno: -104,
code: 'ECONNRESET',
syscall: 'read',
fatal: true
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! xxx#1.0.0 start: `node app.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the xxx#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
This happens when the server is up for few hours. I want to keep it up till I force stop.
I also tried this with nodemon app.js
"ECONNRESET" means the other side of the TCP conversation abruptly closed its end of the connection. This is most probably due to one or more application protocol errors. You could look at the API server logs to see if it complains about something.
But since you are also looking for a way to check the error and potentially debug the problem, you should take a look at "How to debug a socket hang up error in NodeJS?" which was posted at stackoverflow in relation to an alike question.

npm start throwing error when trying to create a react app

I am new to web development using react. So, i did the following -
npm install -g create-react-app
create-react-app my-app
cd my-app
npm start
But, it is throwing a error which are as follows:
E:\Study\React-course\React-app\my-app>npm start
> my-app#0.1.0 start E:\Study\React-course\React-app\my-app
> react-scripts start
i 「wds」: Project is running at http://192.168.1.5/
i 「wds」: webpack output is served from
i 「wds」: Content not from webpack is served from E:\Study\React-course\React-app\my-app\public
i 「wds」: 404s will fallback to /
Starting the development server...
events.js:291
throw er; // Unhandled 'error' event
^
Error: spawn cmd ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)
at onErrorNT (internal/child_process.js:468:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:274:12)
at onErrorNT (internal/child_process.js:468:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
errno: -4058,
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! my-app#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-app#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\asus\AppData\Roaming\npm-cache\_logs\2020-07-20T07_10_52_845Z-debug.log
E:\Study\React-course\React-app\my-app>
Instead of using this (npm install -g create-react-app create-react-app) try creating react app using ( npx create-react-app my-app)
And for more clarification follow this
https://create-react-app.dev/docs/getting-started/
Please do not write a special character on your local system folder

Create-react-app not working at "npm start" even though correct npm/node version [duplicate]

This question already has answers here:
npm start issues with react-scripts 3.4.0
(5 answers)
Closed 2 years ago.
I am learning react following this tutorial. I got an error about not having a start script which, using my text editor I added to the package.json file. Now I don't really know how to fix what my new error is.
Updated my package-json file, uninstalled and reinstalled create-react-app, made new react-app folder, read through stack overflow. start it manually with "npx react-scripts start".
My npm -v (6.7.0) and node -v (12.16.0)
File directory tree of react-app
node_modules
list of folders that were added upon making folder using create-react-app
public
favicon.ico
index.html
manifest.json
src
index.js
.gitignore
package.json
package-lock.json
README.md
Error:
circulating#CLAPP-T460-22 MINGW64 ~/Desktop/react-app (master)
$ npm start
> react-app#1.1.0 start C:\Users\circulating\Desktop\react-app
> react-scripts start
i 「wds」: Project is running at http://192.168.1.16/
i 「wds」: webpack output is served from
i 「wds」: Content not from webpack is served from C:\Users\circulating\Desktop\re act-app\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! react-app#1.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-app#1.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional log ging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\circulating\AppData\Roaming\npm-cache\_logs\2020-06-07T01_ 12_36_919Z-debug.log
Add C:\Windows\System32 to the global PATH environment variable.
or
reinstall your npm with a different react script version. Simply go to your folder in command and reinstall like this:
npm install react-scripts#2.1.8
npm start

npm start issues with react-scripts 3.4.0

I know this question has already been asked but I can't find a solution. When I run npm start inside a react project, I always get the same logs (see below). The only solution given is to uninstall node_modules and re-do the installation. I also tried to clear the cache. Nothing worked.
Some people solved this problem upgrading to react-scripts 3.4.0 (https://github.com/facebook/create-react-app/issues/8490) but that didn't work for me. The only solution I have now is to downgrade react-scripts to version 2.1.8 by using npm install react-scripts#2.1.8. But it's not a good solution because I have to work on a framework that uses the latest version.
here are the logs :
i 「wds」: Project is running at http://192.168.43.27/
i 「wds」: webpack output is served from /
i 「wds」: Content not from webpack is served from C:\Users\fthom\Desktop\temp\my-app\public
i 「wds」: 404s will fallback to /index.html
Starting the development server...
events.js:288
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! my-app#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-app#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\fthom\AppData\Roaming\npm-cache\_logs\2020-02-21T10_59_13_574Z-debug.log
I finally found a solution. Add the default variables in the machines PATH:
C:\Windows\system32
C:\Windows
C:\Windows\System32\Wbem
Screenshot of variables location
Changing the path worked for me.
Just to add, on the above solution for those who didn't know how to change the path (same as me) and some more details.
Here is my way on how to change environment variables on Windows 10:
Open the Start Search, type in “env”, and choose “Edit the system environment variables”
Click the Environment Variables… button.
Go on system variables and under variables find PATH, mark it and click EDIT.
On the end of the list add paths - you can simply click on new or on the empty field on the end of list:
C:\Windows\system32
C:\Windows
C:\Windows\System32\Wbem
Remember to have the npm paths as well:
C:\Program Files\nodejs
C:\Users{yourName}\AppData\Roaming\npm
Set the environment variables as needed.
The New button adds an additional variable. ...
Dismiss all of the dialogs by choosing OK. Your changes are saved!
Restart the computer.
Now it should work!
It took me two days to resolve this issue.
Its because of the incompatibility issue of react-scripts so try installing different versions like:
This worked for me:
npm install --save react-scripts#2.1.8
This one did work for many as they claim:
npm install --save react-scripts#3.3.0
It should work as it did to me after an arduous struggle.
Sometimes on windows, I get the same error message randomly if the npm cache is somehow messed up.
Try to run
npm cache clean --force
Delete the node_modules folder and the package.lock.json file and run npm install afterward.
Open the Start Search, type in “env”, and choose “Edit the system environment
variables
Click the Environment Variables Button.
Go on system variables and under variables find PATH, mark it and click EDIT.
On the end of the list add paths - you can simply click on new or on the empty field
Go to your react app folder then go to node_modules and then go to bin folder and then copy url
Paste your url in new path

Problem with npm start (error : spawn cmd ENOENT)

I have a problem with my application. Because before when I created an application it worked, but now, it shows me this error and I do not know why and the things I have to do to fix it.
Do you have any idea to help me ? (This is a reactJS app).
I checked some stackoverflow topics but everywhere I checked, it was not really an answer that worked.
events.js:180
throw er; // Unhandled 'error' event
^
Error: spawn cmd ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
at onErrorNT (internal/child_process.js:456:16)
at processTicksAndRejections (internal/process/task_queues.js:77:11)
Emitted 'error' event at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12)
at onErrorNT (internal/child_process.js:456:16)
at processTicksAndRejections (internal/process/task_queues.js:77:11) {
errno: 'ENOENT',
code: 'ENOENT',
syscall: 'spawn cmd',
path: 'cmd',
spawnargs: [ '/c', 'start', '""', '/b', 'http://localhost:3000/' ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fix-react-module#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the fix-react-module#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\Lucas\AppData\Roaming\npm-cache\_logs\2019-07-16T09_33_39_111Z-debug.log
Add C:\Windows\System32 to the global PATH environment variable.
Solution 1
Set your environment variable to C:\Windows\System32 . This works for me.
Sets System variable
Solution 2
If the first one doesn't work follow the 2nd steps. Navigate to your project folder and type this command >>>
rm -rf node_modules
rm package-lock.json
rm yarn.lock
npm cache clear --force
npm install
Solution 3
Downgrade react-scripts in package.json file
I had the same problem after I tried to install Mongo DB. I found out that this problem only exists with react-scripts#3.0.0. Try to reinstall your npm with a different react script version. Simply go to your folder in command and reinstall like this:
npm install react-scripts#2.1.8
npm start
After that the app worked for me again.
For all those Who've come to this problem from react scripts not starting. The solution is
Go to search bar and write environment variables. You should see an option to called edit system environment variables or something similar.
Under the Advanced section there is a enivronment variable button. click it.
After that you will see an option named path click on it.
click add button and add following directory C:\Windows\System32.
close down your editor and restart your command terminal.
Problem should be resolved now 😁
If someone hits this coming from Angular 2+, remove the --open from ng serve or run without this option.

Resources