3

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?

user2950593
  • 9,233
  • 15
  • 67
  • 131
  • Does the path `C:\Program Files\AwesomeProject` exist and if not can your current user create it with their set of permissions? – tkone Jan 06 '16 at 18:35
  • @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 Jan 06 '16 at 19:02
  • 1
    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 Jan 06 '16 at 19:11
  • 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: https://github.com/facebook/react-native/issues/5414 – zipzit May 10 '16 at 17:05

5 Answers5

8

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

Martin Konicek
  • 39,126
  • 20
  • 90
  • 98
4

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.

Tapan Dabhi
  • 376
  • 4
  • 7
  • 1
    Could you please elaborate on how to solve the issue if there is no other projects at hand? – Oleg Kurbatov Apr 22 '20 at 17:12
  • @OlegKurbatov you can refer this [link](https://stackoverflow.com/questions/44860306/what-is-gradle-wrapper-and-gradlew-bat-file) for more info – Tapan Dabhi Jun 03 '20 at 21:23
1

enter image description here

react-native-cli@0.1.8 error

Rollback react-native-cli@0.1.7

everything is ok.

Alex McMillan
  • 17,096
  • 12
  • 55
  • 88
Asherwang
  • 42
  • 1
  • 4
    Thanks for answering, but this could communicate a lot better if you used `text` instead of an image and full sentences. – Brad Koch Jan 07 '16 at 01:38
0

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.

Nick Zuber
  • 5,467
  • 3
  • 24
  • 48
ragmha
  • 631
  • 7
  • 19
0

Delete gradlew.bat & gradlew file from this path project/android/ and copy that files from another react native project & paste this into thi path project/android/ then run npm install & run the project.

Alfaiz Khan
  • 91
  • 1
  • 8