• 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
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 785 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 3.5K 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 13 views
Problem: dyld: library not loaded: /usr/local/opt/gettext/lib/libintl.8.dylib
asked Feb 12 Shovo210 3.1k points
0 votes
1 answer 22 views
0 votes
1 answer 371 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
0 votes
2 answers 87 views
On trying to run the command below there show some errors. $ gulp build In my terminal and I get this assertion error. I've uninstalled node and NPM and reinstalled again using brew - How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X) with these steps. My ... /**/*'], [panini.refresh]); }); // Erases the dist folder gulp.task('reset', function() { rimraf('bulma/*');
asked Oct 30, 2020 psandprop 2.4k points
0 votes
1 answer 52 views
0 votes
2 answers 563 views
Problem : I want to to run my NodeJS version with the nvm but getting following error: $ nvm use v4.2.4 nvm is not compatible with the npm config "prefix" option: currently set to "/Users/z/.npm-global"Run `npm config delete prefix` or `nvm use --delete- ... it. I have set the prefix on purpose to avoid the sudo npm How can I use nvm without losing the prefix for my globally installed packages?
asked Nov 29, 2019 alecxe 7.5k points
0 votes
1 answer 3 views
Problem : xcode-select: error: invalid developer directory '/library/developer/commandlinetools'
asked 1 day ago Shovo210 3.1k points