Nitin Tushir
Nitin Tushir

Reputation: 43

Error in installing :- npm install -g create-react-app

I was going through "Modern React with Redux Course" on Udemy, there instructor asked to install NodeJs first and then to install " npm install -g create-react-app", When i tried to run this command , i got an error :-

npm install -g create-react-app
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:
npm ERR!    '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! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/nitintushir/.npm/_logs/2019-09-20T15_22_12_437Z-debug.log

then i go through a some questions on stackoverflow, where someone suggests to run this command :-

 npm cache clean --force

to which i got :

npm WARN using --force I sure hope you know what you are doing.

then i run the

npm install -g create-react-app

command again , but still got the same error , any solution/suggestion ?

Upvotes: 4

Views: 496

Answers (2)

Hamed Navvabian
Hamed Navvabian

Reputation: 792

You should use nvm to manage your node and npm versions. https://github.com/nvm-sh/nvm

This would allow you to globally install node modules without any sudo permission

And also you can change your node version anytime you want with nvm CLI

Upvotes: 2

Saxtheowl
Saxtheowl

Reputation: 4658

It look like an access right error, you should try running your install as root like:

sudo npm install -g create-react-app

Upvotes: 2

Related Questions