I am unable to create a new React Native project via react-native init <ProjectName>
.
This is the first time I've tried since upgrading to macOS Sierra, but I don't know if that's related.
If I run the command with the --verbose
flag, it runs through all the npm packages, but then eventually outputs the following:
├── UNMET PEER DEPENDENCY react@~15.3.1
<List of other packages including react-native 0.34.1>
npm WARN [email protected] requires a peer of react@~15.3.1 but none was installed.
npm verb
npm verb If you need help, you may report this error at:
npm verb <https://github.com/npm/npm/issues>
npm verb exit [ 0, true ]
npm info ok
It then just sits there indefinitely. Last time I created a react native project it would take maybe 20-30 seconds max, but now it never completes (after say 10-15 minutes).
If I kill the process, all I have is a package.json with just the following in:
{
"name": "TestApp",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start"
},
"dependencies": {
"react-native": "0.34.1"
}
}
...and the node_modules folder containig react-native and its dependencies. None of the required XCode/Android folders are there, or the index entry points, configs etc.
I have tried reinstalling all the required dependencies (node, homebrew) and I have also reinstalled git via homebrew.
I've seen other threads that suggest manually installing React, but I don't buy it. This used to work and React used to get installed as part of the process, but now I get this warning and it's game over.
Anyone else seen this issue?
EDIT
I just tried this on my other Mac, also running macOS Sierra and it worked fine. I followed the same steps on that to ensure all my dependencies were up to date first. I did a verbose init and still got the warning about React 15.3.1 being missing, but it then carried on and install Reacrt 15.3.2 and then set up all the XCode/Android project files.
Very odd/annoying as I really need to start putting something together on this Mac.
SECOND EDIT
If I create a new user account on my Mac and log in as that, I can create a project, so it seems to be user-specific. Although annoying, I don't mind setting a new account up, but before I do would like to see if anyone can offer any suggestions. Thanks.
So the issue turned about to be watchman, as outlined here: https://github.com/facebook/react-native/issues/9943
If I ran watchman version
the terminal hung, so as per the instructions I did:
rm -rf /usr/local/var/run/watchman/ && brew uninstall watchman && brew install watchman
...and it worked a treat!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With