0

NPM is not working it's giving permission denied error. Here is the full log:

npm ERR! code 128
npm ERR! Command failed: /usr/bin/git clone --depth=1 -q -b master git://github.com/jonschlinkert/resolve-file.git /root/.npm/_cacache/tmp/git-clone-8b5c9e7d
npm ERR! fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone-8b5c9e7d': Permission denied
npm ERR!

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-04-11T06_46_34_324Z-debug.log
root@ip-172-31-15-60:/var/www/html/itracker# npm install request
npm ERR! code 128
npm ERR! Command failed: /usr/bin/git clone --depth=1 -q -b master git://github.com/jonschlinkert/resolve-file.git /root/.npm/_cacache/tmp/git-clone-77c3de2c
npm ERR! fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone-77c3de2c': Permission denied
npm ERR!

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-04-11T06_47_05_916Z-debug.log

What i tried:

  • completely removed node and NPM and installed.

    sudo chown -R $(whoami) ~/.npm

by following the answer from here: npm throws error without sudo

Note:

I tried to install globally is working. But installing locally is not working. I tried both sudo and normal user.

Sarath Kumar
  • 1,136
  • 1
  • 18
  • 41

2 Answers2

4

try sudo npm install even if you are working on sudo user

Basil Battikhi
  • 2,638
  • 1
  • 18
  • 34
0

Use the latest npm

npm install -g npm 
Adonis
  • 4,670
  • 3
  • 37
  • 57
Shubham Azad
  • 786
  • 2
  • 10
  • 25