Why npm start is getting error for react project? - node.js

I'm trying to start a React application, with npm but I get this error:
events.js:174
throw er; // Unhandled 'error' event
^
Error: spawn cmd ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
Emitted 'error' event at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
I'm using node version 10.16.3 and npm 6.13.6. I've cleaned npm cache and install npm again, but I'm getting always the same error

I suggest doing these three steps:
npm install -g npm#latest to update npm because it is sometimes buggy.
rm -rf node_modules to remove the existing modules.
npm install to re-install the project dependencies.

the problem is fixed , i've installed another version of "react-scripts" , because the actuel version is not stable , so i use to overwrite it with the given version, so use this command to install :
npm install react-scripts#2.1.8
Once the installation is completed your can run your reac app :
npm start

Related

npm start react issue

i have alawys use npm start to run a React application
these days i try to use this command i got an error
and it goes like this
ps: i'm using ubuntu 20.04
node:events:371
throw er; // Unhandled 'error' event
^
Error: spawn brave ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19)
at onErrorNT (node:internal/child_process:480:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (node:internal/child_process:288:12)
at onErrorNT (node:internal/child_process:480:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn brave',
path: 'brave',
spawnargs: [ 'http://localhost:3000' ]
}
I have deleted the cache,
I did delete node_modules and run npm install
and still i face the same problem
and if i use sudo npm start everything works fine
I think you installed node with root permission, that we lead to restricting non-sudo to use global packages.
I suggest that you remove the current node installation, and use nvm instead to install the desired node version https://github.com/nvm-sh/nvm.
after that, you need to install react-create-app again.

How to resolve these errors form updated Node & npm versions ..?

I update the Node latest version to 15.0.1 & npm 7.0.3. After i installed node modules and run my project with npm start its showing these type of errors....
cross-env NODE_ENV=development webpack-dev-server --open --config webpack.dev.js
node:events:304
throw er; // Unhandled 'error' event
^
Error: spawn webpack-dev-server ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:269:19)
at onErrorNT (node:internal/child_process:465:16)
at processTicksAndRejections (node:internal/process/task_queues:80:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (node:internal/child_process:275:12)
at onErrorNT (node:internal/child_process:465:16)
at processTicksAndRejections (node:internal/process/task_queues:80:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn webpack-dev-server',
path: 'webpack-dev-server',
spawnargs: [ '--open', '--config', 'webpack.dev.js' ]
}
npm ERR! code 1
npm ERR! command failed
npm ERR! command sh -c cross-env NODE_ENV=development webpack-dev-server --open --config webpack.dev.js
npm ERR! A complete log of this run can be found in:
npm ERR! /home/krishnasai/.npm/_logs/2020-10-28T09_44_19_855Z-debug.log
feels to me that you installed cross-env globally, and it might break whenever you switch node versions.
i would advise you to have cross-env in the dependency of your project. you can do that by installing cross-env and specify that you would like to save it in your package.json.
try this
npm install --save-dev cross-env
then try again to run your project.

npm start fails with events.js:174 throw err; on Ubuntu 18.04

I have been trying to get the basic electron-quick-start demo working on Ubuntu 18.04. Everything works up to the point that I try: npm start at which point I get this error:
> electron .
events.js:174
throw er; // Unhandled 'error' event
^
Error: spawn /home/me/docs/electron-quick-start/node_modules/electron/dist/electron EACCES
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
at Function.Module.runMain (internal/modules/cjs/loader.js:757:11)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
Emitted 'error' event at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)
at onErrorNT (internal/child_process.js:415:16)
[... lines matching original stack trace ...]
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! electron-quick-start#1.0.0 start: `electron .`
npm ERR! Exit status 1
I have tried clearing the npm cache, rebooting, and nothing seems to work.
There seem to be two versions of node.js installed:
node -v ==> v10.15.3
nodejs -v ==> v11.15.0
Both these versions are probably the result of trying to upgrade node.js to a newer version than what comes with Ubuntu, though I don't know why or how. I upgraded following the instructions on this webpage - https://github.com/nodesource/distributions:
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
When that didn't work I tried again with vers 11.x.
My version of npm is: 6.9.0
Why are there two versions of node.js? Could this be the problem?
What should I do to get npm start to work? If clearing everything and starting over is the best approach, I am all for it. This is my first time using node.js, so I am totally lost here. BTW, downloaded electron apps (e.g. VS Code) seem to be working just fine if that's any help.
Solution 1: Try to find the exacly npm/node version your project are using to install.
Better use a npm version manager like nvm.
Solution 2: On linux bash execute:
sudo sysctl fs.inotify.max_user_watches=524288
sudo sysctl -p
The reason?
the OS have a max handle files count. You need to increase this.
Why?
did you realize how many files the node_modules folder has on the smallest/simplest project you have? Now, try to imagine on medium/large project.

Error when create jhipster sample 21-points application

Follow the official guide I installed nodejs, yoman, bower, gulp and generator-jhipster in my mac. After executed "yo jhipster" command it shows something error occured. Where is wrong? I can run "./mvnw" and startup server but the home page hints me there is something error.
npm install -g yo
npm install -g bower
npm install -g gulp
npm install -g generator-jhipster
yo jhipster
...
bootstrap#3.3.7 src/main/webapp/bower_components/bootstrap
└── jquery#3.1.0
events.js:160
throw er; // Unhandled 'error' event
^
Error: spawn gulp ENOENT
at exports._errnoException (util.js:1026:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:359:16)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
it should be npm install -g gulp-cli
See the doc:
Install Gulp: npm install -g gulp-cli (If you have previously
installed a version of gulp globally, please run npm rm -g gulp to
make sure your old version doesn’t collide with gulp-cli)
Also take care of using an LTS version of NodeJS.

react native windows, spawn npm ENOENT error

I am trying to run react-native on windows and get the following error:
C:\Program Files>react-native init AwesomeProject
This will walk you through creating a new React Native project in
C:\Program Fil es\AwesomeProject Installing react-native package from
npm... events.js:141
throw er; // Unhandled 'error' event
^
Error: spawn npm ENOENT
at exports._errnoException (util.js:860:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
at onErrorNT (internal/child_process.js:344:16)
at doNTCallback2 (node.js:450:9)
at process._tickCallback (node.js:364:17)
at Function.Module.runMain (module.js:459:11)
at startup (node.js:136:18)
at node.js:972:3
How do I fix this?
This should be fixed in React Native CLI 0.1.9. To update your CLI:
npm uninstall -g react-native-cli
npm install -g react-native-cli
There was a regression in 0.1.8, reported here: https://github.com/facebook/react-native/issues/5169
Check if the gradlew.bat file is present in the android folder if it is not there then simply copy gradlew.bat file from another project.
react-native-cli#0.1.8 error
Rollback react-native-cli#0.1.7
everything is ok.
To fix this, Reinstall NodeJS https://nodejs.org/en/
Then
npm install -g react-native-cli --vebrose
react-native init App --verbose
If it still fails, try installing Python 3 https://www.python.org/ and repeat the process.

Resources