2
votes

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?

4
Does the path C:\Program Files\AwesomeProject exist and if not can your current user create it with their set of permissions?tkone
@tkone, yes it does. It has 1 file package.json with the following code there {"name":"AwesomeProject","version":"0.0.1","private":true,"scripts":{"start":"node node_modules/react-native/local-cli/cli.js start"}}user2950593
is there anymore to your error message? ENOENT means that its trying to access a directory/file that doesn't exist. Can you change the log level on the command?tkone
So apparently this was fixed in react-native 0.1.9 in windows as long as you don't use the --verbose feature in your init call, ref: github.com/facebook/react-native/issues/5414zipzit

4 Answers

1
votes
8
votes

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

3
votes

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.

0
votes

To fix this, Reinstall NodeJS https://nodejs.org/en/

enter image description here

Then

npm install -g react-native-cli --vebrose
react-native init App --verbose

enter image description here

If it still fails, try installing Python 3 https://www.python.org/ and repeat the process.