2

I have been trying to use react native and create a project but have not been able to do so.

I am using the instructions from https://facebook.github.io/react-native/docs/getting-started.html

Node and watchman are already installed and then when I enter:

npm install -g react-native-cli

I get this:

/usr/local/bin/react-native -> /usr/local/lib/node_modules/react-native-cli/index.js
[email protected] /usr/local/lib/node_modules/react-native-cli
├── [email protected]
├── [email protected]
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])

When I try to do:

react-native init AwesomeProject

I get:

This will walk you through creating a new React Native project in /Users/jaimito/AwesomeProject
Installing react-native package from npm...

npm WARN peerDependencies The peer dependency react@~15.2.1 included from react-native will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency 
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm ERR! Darwin 15.6.0
npm ERR! argv "/usr/local/Cellar/node/6.4.0/bin/node" "/usr/local/bin/npm" "install" "--save" "--save-exact" "react-native"
npm ERR! node v6.4.0
npm ERR! npm  v2.15.9
npm ERR! path /Users/jaimito/.npm/optimist/0.6.1
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall mkdir

npm ERR! Error: EACCES: permission denied, mkdir '/Users/jaimito/.npm/optimist/0.6.1'
npm ERR!     at Error (native)
npm ERR!  { Error: EACCES: permission denied, mkdir '/Users/jaimito/.npm/optimist/0.6.1'
npm ERR!     at Error (native)
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/Users/jaimito/.npm/optimist/0.6.1',
npm ERR!   parent: 'react-native' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/jaimito/AwesomeProject/npm-debug.log

`npm install --save --save-exact react-native` failed

How do I prevent the errors?

I am working on a Mac.

I used sudo at the beginning of the command. But when I did:

cd AwesomeProject
react-native run-ios

I got:

fs.js:640
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: EACCES: permission denied, open '/Users/jaimito/.babel.json'
    at Error (native)
    at Object.fs.openSync (fs.js:640:18)
    at Object.fs.writeFileSync (fs.js:1333:33)
    at save (/Users/jaimito/AwesomeProject/node_modules/react-native/node_modules/babel-register/lib/cache.js:53:16)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)
    at Module.runMain (module.js:592:11)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3

I tried using sudo at the beginning and I got this:

fs.js:640
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: EACCES: permission denied, open '/Users/jaimito/.babel.json'
    at Error (native)
    at Object.fs.openSync (fs.js:640:18)
    at Object.fs.writeFileSync (fs.js:1333:33)
    at save (/Users/jaimito/AwesomeProject/node_modules/react-native/node_modules/babel-register/lib/cache.js:53:16)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)
    at Module.runMain (module.js:592:11)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3
~
Process terminated. Press <enter> to close the window
2
  • try : chmod 777 on "/Users/jaimito/.npm/optimist/0.6.1" Commented Aug 22, 2016 at 20:32
  • or try to run command with sudo Commented Aug 22, 2016 at 20:33

3 Answers 3

2

Try starting the command with sudo, it'll give your command the permission to create directories in the necessary places.

Sign up to request clarification or add additional context in comments.

2 Comments

I used sudo but now I have a new problem when I try running it. Also is there a way to not have to use sudo?
sudo is not a valid solution for mkdir a directory in your home dir ...
0

If you're on windows, try open the command line with admin permissions.

If you're on mac or linux, type sudo at the begining of the command.

Either way. Make sure your target directory doesn't already exist.

Comments

0

For me the marked directory inside the .npm directory belonged to root:wheel. Try to get it back ;) (or the 0.3.* directory inside marked)

chown -R `whoami` ~/.npm/marked

Or if necessary

sudo chown -R `whoami` ~/.npm/marked

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.