• Register
1 vote

Problem :

I am beginner to the monaca. Currently I am trying to install the monaca with the use of below command.

npm install -g monaca
But I am facing below errors after executing above command:
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' }
I am struggling with above error from past couple of days. Can somebody help me in fixing above monaca error?
8 5 2
3,230 points

Please log in or register to answer this question.

2 Answers

1 vote

Solution :

To fix your error please follow below process.

You need to add below lines of code to your ~/.bashrc after installing your npm:

npm set prefix ~/.npm

Execute following line after changes : source ~/.bashrc

If you are using the Zsh then you need to add the lines above to ~/.zshrc after installing npm.

npm set prefix ~/.npm; 

Execute following line after changes: source ~/.zshrc

And most important thing is to avoid using sudo

8 4 1
5,680 points
0 votes


The first time you attempt to install a package globally employing npm, ecercising the syntax npm install -g <package> on a Mac, or Linux, you might obtain a weird error, saying something like

Missing write access to /usr/local/lib/node_modules

or something along those lines, pursued by a long list of other errors of warnings, a outcome of the first error that’s printed to you.

This error is opposing us to install the package.

This is how to solve it. Run this command:

sudo chown -R $USER /usr/local/lib/node_modules

Let’s break it down:

sudo implies we are running this command as root, the method super user. This is since we don’t have permission to write to that folder, however root will be able to solve any permission. This command also implies the system will ask for your password to ensure.

chown is the command we employ to alter the owner of a file or folder. We place the -R option to change the owner recursively, hence we also obtain owner access to all the files meanwhile contained in there.

$USER is an environment variable automatically place to your username.

And the last piece is the folder path.

Running this path will create the folder yours, hence you can safely run your npm install -g <package> commands!

Run these commands in a terminal window:

sudo chown -R $USER ~/.npm
sudo chown -R $USER /usr/lib/node_modules
sudo chown -R $USER /usr/local/lib/node_modules

Employing sudo is not recommended. It may provide you permission problem later. While the above performs, I am not a fan of altering folders owned by root to be writable for users, though it may only be an problem with multiple users. To perform around that, you could use a group, with 'npm users' however that is also more administrative overhead. View here for the options to deal with permissions from the documentation:

To diminish the scope of permissions errors, you can configure npm to use a different directory. In this instance, it will be a hidden directory on your home folder.

Create a directory for global installations:

mkdir ~/.npm-global

Configure npm to employ the new directory path:

 npm config set prefix '~/.npm-global'

Open or create a ~/.profile file and include this line:

export PATH=~/.npm-global/bin:$PATH

Back on the command line, update your system variables:

 source ~/.profile

Examine: Download a package globally without employing sudo.

npm install -g jshint

In case still show permission error run (mac os):

sudo chown -R $USER ~/.npm-global   

This performs with the default ubuntu install of:

sudo apt-get install nodejs npm


10 6 4
31,120 points

Related questions

0 votes
1 answer 895 views
Problem : I am new to npm and now I am facing strange looking below error &ldquo;Error: EACCES: permission denied, access '/usr/local/lib/node_modules'&rdquo; Detailed error as below: npm ERR! path /usr/local/lib/node_modules npm ERR! code EACCES npm ERR! errno -13 npm ... code: 'EACCES', npm ERR! syscall: 'access', npm ERR! path: '/usr/local/lib/node_modules' } Have somebody fixed this before?
asked Feb 20, 2020 mphil 2.3k points
0 votes
1 answer 41 views
Problem: HELP! I need help understanding this error :Local package.json exists, but node_modules missing, did you mean to install?.
asked Mar 6 Wafa Abu Yousef 6.1k points
0 votes
1 answer 4.2K views
Problem : I am trying to start the Redux application I just cloned from the GitHub repository. I tried to run it with the below command npm start But I am getting below error > react-redux@1.0.0 start /home/workspace/assignment > webpack-dev-server --config ./ ... output above. npm WARN Local package.json exists, but node_modules missing, did you mean to install? How can I fix the above error?
asked Jan 20, 2020 jwilliam 3.9k points
0 votes
1 answer 24 views
Problem : I cannot call a bind from onchanged.I'm making list using onsenui and react.I get this : Typeerror: cannot read property 'bind' of undefined I couldn't figure out.... Does anyone can solve this?
asked Mar 21 Sabbir Hossain 14.6k points
1 vote
1 answer 39 views
Problem : Why React JSX file giving Error: TypeError: Cannot read property 'createElement' of undefined at Object.<anonymous> (/Users/me/projects/myproj/test/test_stuff.js:7:7) What does that mean? How to fix this ?
asked Mar 21 Sabbir Hossain 14.6k points
0 votes
1 answer 1 view
1 view
Problem: I installed node using homebrew (Mojave), afterwards php stoped working and if I try to run php -v I get this error:php -v dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib Referenced from: /usr/local/bin/php Reason: image not found.I tried to uninstall both node and icu4c but the problem persists.
asked 6 days ago sumaiya simi 43.9k points
0 votes
1 answer 57 views
Problem: dyld: library not loaded: /usr/local/opt/gettext/lib/libintl.8.dylib
asked Feb 12 Sabbir Hossain 14.6k points
0 votes
1 answer 45 views
0 votes
1 answer 423 views
Problem : Currently I am learning Homebrew (Mojave). Recently I tried to install the node using Homebrew (Mojave) but after sometime my Php stopped working and now if I try to run the command php -v I face below error: php -v dyld: Library not loaded: /usr/local ... from: /usr/local/bin/php Reason: image not found I have also tried to uninstall my both node and icu4c but my problem still persists
asked Feb 20, 2020 mphil 2.3k points