Search code examples
javascriptreactjsmacosnpmmonaca

npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules


Note: Due to security concerns, please don't use the marked solution but instead the highest voted one!


original question:

I am trying to install monaca with this command.

npm install -g monaca

But right after getting these errors:

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' }

Any idea how to solve this problem? Thank you


Solution

  • An inadvisable way to fix the issue would be to use sudo:

    sudo npm install -g monaca
    

    However it would be better to find a way around this without using sudo.

    npm install -g less does not work