12

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
johnny04501
  • 279
  • 1
  • 2
  • 11
  • https://stackoverflow.com/questions/31744852/npm-install-giving-error-while-accessing-git-url This question may help. – evolutionxbox Dec 27 '17 at 17:57
  • 1
    npm comes installed together with install of node ... I avoid using sudo ... if you do install node using sudo then all npm install commands must also issue sudo ... if you avoid sudo during install then never use `sudo npm install x` ... install without sudo can be either a raw source code install or a compiled install ... read the inline comments https://askubuntu.com/questions/426750/how-can-i-update-my-nodejs-to-the-latest-version/959382#959382 – Scott Stensland Dec 27 '17 at 23:56

3 Answers3

39

this solution worked for me

 sudo sudo npm install
Unkas
  • 3,522
  • 2
  • 19
  • 23
  • 9
    While this code may answer the question, providing additional context regarding how and/or why it solves the problem would improve the answer's long-term value. – Nic3500 Aug 05 '18 at 01:16
  • 2
    ...especially that double `sudo` would warrant some explanation beyond "I threw commands at the wall to see what would stick". – Robert Aug 05 '18 at 02:51
  • 3
    This solution looks stupid but actually very genious and worked out for me :D – vineetv2821993 Aug 24 '18 at 20:43
  • 9
    It worked for me too, so checked the idea behind `sudo sudo`. The reason why it works, is that the second `sudo` is invoked as root which has the permissions to impersonate other users without requiring a password. So the command that previously gave Permission deny, works - because of the way sudo is configured (`NOPASSWD:` in sudoers) it doesn't need a password to execute as root. – Nikita Kurtin Mar 11 '19 at 12:23
  • Beat me to it, how come we are writing explanation one year after the answer at the exact same time? :) – F.H. Apr 11 '19 at 07:26
  • 1
    incredible, worked out for me. Thanks **Nikita Kurtin** for description – cinobili19 May 07 '19 at 07:08
1

Here what worked for me: login as root,and type

sudo su
npm install -g npm 

Not sure if it's the same problem i had, but worth a try.

Contropist
  • 401
  • 4
  • 9
1

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

sudo npm install --unsafe-perm=true

Raghav Jajodia
  • 419
  • 4
  • 6