When trying to create a new react-native project there an error while installing packages.
react-native init
Reproduced over here too. Trying to init a new project.
Same error with me.
Cannot find module 'invariant'
We get it as well when "running" the react-native Examples (latest master) in Xcode.
react-native-cli: 1.3.0
macOS Sierra: 10.12.1
... but only on one of our machines (the other is fine with the same versions).
Fixed it here by running npm i --save-dev invariant
on the react-native
cloned repo, which is obviously a temporary solution, and I doubt that would work with the CLI.
node: v4.4.7
npm: 2.15.8
And we get no problem with the actual cli init command!
work for me.
npm cache clean
npm uninstall react-native-cli -g
npm install react-native-cli -g
react-native init myapp
+1 :S
Same issue here. I tried herudi's solution and still got the same error, but it worked after updating npm to the latest version (npm install npm@latest -g
).
Old npm version: 2.15.8
New npm version: 4.0.3
npm cache clean
npm uninstall react-native-cli -g
npm install react-native-cli -g
react-native init myapp
It worked for me but it installed package dependencies through yarn v0.16.1
Like skonves, I updated npm to 4.0.3 and tried herudi's solution. No luck for me, but I was able to get it working by just installing invariant globally. Kinda hacky, but it works for me.
npm install -g invariant
Like haustraliaer, npm i --save-dev invariant
worked for me.
npm i --save-dev invariant
worked for me
skonves solution worked for me
@skonves npm install npm@latest -g
solution works for me.
npm i --save-dev invariant work for me.
@herudi +1
@skonves +1 for figuring that older NPM versions have an issue here great job :)
This worked for me:
```- npm cache clean
upgrade npm works for me ,thanks a lot~
@skonves also worked for me, thanks!
@skonves npm install npm@latest -g solution works for me.
Upgraded npm then follow @herudi commands worked for me.
- npm install npm@latest -g
- npm cache clean
- npm uninstall react-native-cli -g
- npm install react-native-cli -g
- react-native init myapp
@skonves It worked for me too,thanks
npm i --save-dev invariant
works for me
Upgrading npm with npm install npm@latest -g
fixed for me.
A note for anyone getting this issue with anymatch
not being found.
Doing a npm i --save-dev anymatch
fixes the problem. Seems like this may work for a few packages not being found.
Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally!
If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:
If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.
Most helpful comment
Same issue here. I tried herudi's solution and still got the same error, but it worked after updating npm to the latest version (
npm install npm@latest -g
).Old npm version: 2.15.8
New npm version: 4.0.3