• Register
1 vote
115 views

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

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
PATH="$HOME/.npm/bin:$PATH"
PATH="./node_modules/.bin:$PATH"

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; 
path+=$HOME/.npm/bin; 
path+=./node_modules/.bin

Execute following line after changes: source ~/.zshrc

And most important thing is to avoid using sudo

8 4
5,680 points
0 votes

Solution:

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 591 views
591 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 mphil 2.3k points
0 votes
1 answer 2.1K views
2.1K 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 jwilliam 3.9k points
0 votes
1 answer 7 views
0 votes
1 answer 297 views
297 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 mphil 2.3k points