Cryptic error messages with npm and node

423 Views Asked by At

I'm following facebook's tutorial on getting started with React Native (https://facebook.github.io/react-native/docs/tutorial.html#hello-world), but I can't get the react-native-cli to install. Any help interpreting the error messages? Obviously it says to unlink something, but I don't know what it is linked to that it shouldn't be linked to.

Running as root seems to do something, but zsh still won't recognize the react-native command.

➜  ~  npm install -g react-native-cli
npm ERR! Darwin 14.3.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "-g" "react-native-cli"
npm ERR! node v0.12.4
npm ERR! npm  v2.10.1
npm ERR! path /Users/bbarclay/.node/bin/react-native
npm ERR! code EACCES
npm ERR! errno -13

npm ERR! Error: EACCES, unlink '/Users/bbarclay/.node/bin/react-native'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES, unlink '/Users/bbarclay/.node/bin/react-native']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/Users/bbarclay/.node/bin/react-native' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.
npm ERR! error rolling back Error: EACCES, unlink '/Users/bbarclay/.node    /bin/react-native'
npm ERR! error rolling back     at Error (native)
npm ERR! error rolling back  { [Error: EACCES, unlink '/Users/bbarclay/.node/bin/react-native']
npm ERR! error rolling back   errno: -13,
npm ERR! error rolling back   code: 'EACCES',
npm ERR! error rolling back   path: '/Users/bbarclay/.node/bin/react-native' }

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/bbarclay/npm-debug.log
➜  ~  sudo npm install -g react-native-cli                
Password:
/Users/bbarclay/.node/bin/react-native -> /Users/bbarclay/.node/lib/node_modules/react-native-cli/index.js
[email protected] /Users/bbarclay/.node/lib/node_modules/react-native-cli
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])
➜  ~  react-native init AwesomeProject
zsh: command not found: react-native
1

There are 1 best solutions below

0
On

Add the admin permission to .npm home directory.

sudo chown -R $(whoami) ~/.npm