3

I want to learn React-native and I am following the official docs. and I am using create-react-native-app for installation.

I am also working for a project in reactjs which is also installed using create-react-app. When I tried to install react-native using cmd:

npm install -g create-react-native-app

I see the following error

npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  { Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!   stack: 'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

My mac already has a node_modules which is created during Reactjs Installation.

And when I run npm install create-react-native-app the modules are installed but the cmd for creating react native app didn't get recognized.

$create-react-native-app hello

-bash: create-react-native-app: command not found

Is it possible to work both in react-native and reactjs?

9
  • 2
    sudo chmod -R 777 node_modules let me know if still facing issue . this is the permission issue Commented Aug 16, 2018 at 13:22
  • what command did you issue to get the error? Commented Aug 16, 2018 at 13:25
  • 1
    sudo npm install -g create-react-native-app try this command . it should be work . Commented Aug 16, 2018 at 13:35
  • 1
    because -g used for global and we need root access. sudo will provide root access to your command . so just use sudo in the front of your command Commented Aug 16, 2018 at 13:37
  • 1
    please give ne thumps up to comment if find it helpful :) and for good question i already gives you thumps up Commented Aug 16, 2018 at 16:54

1 Answer 1

2

Anything with -g requires a global install and requires sudo access. Because this installs globally.

sudo npm install -g create-react-native-app
Sign up to request clarification or add additional context in comments.

2 Comments

it was my answer :D
Anila Sindhu. I did see that earlier. I knew the answer before you knew it. I asked him the question as to what command he is using when you were saying that directory had to be chmodded. While I was writing the answer you commented. Thats the diff. I felt I deserved it otherwise I would have said so.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.