Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

permission denied error with npm install

Just made a fresh reinstall of my ubuntu and installed necessarily things such as nodejs npm. If I cloned project and tried sudo npm install I got this error. Had someone same problem?

using node: 8.9.3 npm: 5.5.1

fetchPackageMetaData error for gulp@git://github.com/gulpjs/gulp.git#4ed9a4a3275559c73a396eff7e1fde3824951ebb Command failed: /usr/bin/git clone -q git://github.com/gulpjs/gulp.git /home/user_name/.npm/_cacache/tmp/git-clone-0e191fc9

fetchPackageMetaData /home/user_name/.npm/_cacache/tmp/git-clone-0e191fc9/.git: Permission denied

Error: Command failed: /usr/bin/git clone -q git://github.com/gulpjs/gulp.git /home/user_name/.npm/_cacache/tmp/git-clone-0e191fc9

/home/user_name/.npm/_cacache/tmp/git-clone-0e191fc9/.git: Permission denied
like image 822
johnny04501 Avatar asked Dec 27 '17 17:12

johnny04501


People also ask

How do I give npm permission to install?

Run “npm config get prefix” in your terminal. This will give the path of global node_modules: For ex: /usr/local. Change the user permissions for this folder by using following command: sudo chown -R <user_id> /usr/local/

Why npm is not installing?

On Windows, the cause of this error could be that a PATH or system variable is not correctly set. The error can also occur if you do not have npm or Node. js installed, have an outdated version, or have permission issues.


2 Answers

this solution worked for me

 sudo sudo npm install
like image 132
Unkas Avatar answered Oct 04 '22 13:10

Unkas


Just in case the above solution doesn't work, try running:

sudo npm install --unsafe-perm=true

like image 45
Raghav Jajodia Avatar answered Oct 04 '22 15:10

Raghav Jajodia