Guillaume D
Guillaume D

Reputation: 185

EACCES Issue on npm fresh install on WSL Debian trying to update to the latest version

Hello everyone i started with a fresh wsl distrib of Debian and installed nodejs and npm on it.

When trying to update to the latest release of npm with the following command:

sudo npm install npm@latest -g

I get some weird issues who seems pretty common on wsl from what i saw on my internet researchs the only answer who seems to works but not really resolving properly the issue is setting the unsafe permissions to true with the following command:

npm config set unsafe-perm true

I would avoid to use this method and find an more clean way to resolve the issue.

Here is the console output:

####@#####:~$ sudo npm install npm@latest -g
npm ERR! path /usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/wrap- 
ansi
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall rename
npm ERR! Error: EACCES: permission denied, rename 
'/usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/wrap-ansi' -> 
'/usr/lib/node_modules/.staging/wrap-ansi-9f8997e7'
npm ERR!  { [Error: EACCES: permission denied, rename 
'/usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/wrap-ansi' -> 
'/usr/lib/node_modules/.staging/wrap-ansi-9f8997e7']
npm ERR!   cause:
npm ERR!    { Error: EACCES: permission denied, rename 
'/usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/wrap-ansi' -> 
'/usr/lib/node_modules/.staging/wrap-ansi-9f8997e7'
npm ERR!      errno: -13,
npm ERR!      code: 'EACCES',
npm ERR!      syscall: 'rename',
npm ERR!      path:
npm ERR!       '/usr/lib/node_modules/.staging/npm- 
18aca6f9/node_modules/wrap-ansi',
npm ERR!      dest: '/usr/lib/node_modules/.staging/wrap-ansi-9f8997e7' },
npm ERR!   stack:
npm ERR!    "Error: EACCES: permission denied, rename 
'/usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/wrap-ansi' -> 
'/usr/lib/node_modules/.staging/wrap-ansi-9f8997e7'",
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'rename',
npm ERR!   path:
npm ERR!    '/usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/wrap- 
ansi',
npm ERR!   dest: '/usr/lib/node_modules/.staging/wrap-ansi-9f8997e7' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as 
the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double- 
check the
npm ERR! permissions of the file and its containing directories, or try 
running
npm ERR! the command again as root/Administrator (though this is not 
recommended).

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-03-15T23_53_32_851Z-debug.log

I followed the doc of the nodejs website for installation using curl in root mode to get the repository of the last 11.x version of node.

Thanks in advance!

Upvotes: 4

Views: 2018

Answers (1)

kierrsun
kierrsun

Reputation: 41

Experiencing this issue on WSL Ubuntu distro, and only on rename.

Happens also on npm update even after using chown on my node_modules directory.

The workaround that I got working is to simply avoid update and use install instead (npm install npm@x is technically an update too). I know this is very bothersome but aside from this I'm not sure how to make it work. Commands that rename directories trigger this but not on create or delete.

Upvotes: 4

Related Questions