Afeesudheen
Afeesudheen

Reputation: 1024

npm package fails to install "npm ERR! Error: EACCES: permission denied"

npm ERR! Linux 3.4.0+
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "lodash"
npm ERR! node v5.10.1
npm ERR! npm  v3.8.3
npm ERR! path /root/test/node_modules/.staging/lodash-9a2aabe2
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall rename

npm ERR! Error: EACCES: permission denied, rename '/root/test/node_modules/.staging/lodash-9a2aabe2' -> '/root/test/node_modules/lodash'
npm ERR!     at destStatted (/usr/lib/node_modules/npm/lib/install/action/finalize.js:25:7)
npm ERR!     at FSReqWrap.oncomplete (fs.js:82:15)
npm ERR!
npm ERR! Error: EACCES: permission denied, rename '/root/test/node_modules/.staging/lodash-9a2aabe2' -> '/root/test/node_modules/lodash'
npm ERR!     at Error (native)
npm ERR!  [Error: EACCES: permission denied, rename '/root/test/node_modules/.staging/lodash-9a2aabe2' -> '/root/test/node_modules/lodash']
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     /root/test/npm-debug.log

Upvotes: 2

Views: 18044

Answers (5)

Dhananjaya rajan
Dhananjaya rajan

Reputation: 1

Run this command in the terminal:

sudo chown -R 501:20 "/Users/johnsmith/.npm"

Replace johnsmith and also replace 501:20 with your actual user and group IDs if they are different.

Then close the terminal and reopen the terminal.

Then run npm i {package name}.

It should work correctly.

Upvotes: 0

muhammad mansha
muhammad mansha

Reputation: 11

For my case i run following command

sudo npm install -g <package name> --unsafe-perm=true --allow-root

Upvotes: 1

Brijesh Ray
Brijesh Ray

Reputation: 1263

For my case i run following command, for this permission denied issue:

1st:

sudo npm install -g npm@latest

2nd:

npm install -g [email protected]

3rd: check version:

ng version

Upvotes: 0

Nunya Klah
Nunya Klah

Reputation: 59

Install using this command

sudo npm install -g <package name> --unsafe-perm=true --allow-root

Upvotes: 5

Eddinn
Eddinn

Reputation: 66

install the npm package locally for your user, and if you have to install it globally, use sudo. e.g:

sudo npm install package -g

Upvotes: -1

Related Questions