WSL: NPM global package install throws EACCES error

  • A brief description NPM throws an EACCES error when installing a global package (vue-cli in my case). This happens at a random point in the install, on a random dependency. This could either be a WSL or an NPM issue, but since I can’t find anything about it on the net I figured I’d go for the smaller community first 😃

  • Expected results The package and all its dependencies install

  • Actual results (with terminal output if applicable) At a seemingly random dependency, when writing from .staging to the final node_modules folder, this happens:

npm ERR! Linux 3.4.0+ npm ERR! argv “/usr/bin/nodejs” “/usr/bin/npm” “install” “-g” “vue-cli” npm ERR! node v6.9.1 npm ERR! npm v3.10.8 npm ERR! path /home/matthijs/.npm-global/lib/node_modules/vue-cli/node_modules/mkdirp npm ERR! code EACCES npm ERR! errno -13 npm ERR! syscall rename

npm ERR! Error: EACCES: permission denied, rename ‘/home/matthijs/.npm-global/lib/node_modules/vue-cli/node_modules/mkdirp’ -> ‘/home/matthijs/.npm-global/lib/node_modules/vue-cli/node_modules/.mkdirp.DELETE’ npm ERR! at moveAway (/usr/lib/node_modules/npm/lib/install/action/finalize.js:38:5) npm ERR! at destStatted (/usr/lib/node_modules/npm/lib/install/action/finalize.js:27:7) npm ERR! at FSReqWrap.oncomplete (fs.js:123:15) npm ERR! npm ERR! Error: EACCES: permission denied, rename ‘/home/matthijs/.npm-global/lib/node_modules/vue-cli/node_modules/mkdirp’ -> ‘/home/matthijs/.npm-global/lib/node_modules/vue-cli/node_modules/.mkdirp.DELETE’ npm ERR! at Error (native) npm ERR! { Error: EACCES: permission denied, rename ‘/home/matthijs/.npm-global/lib/node_modules/vue-cli/node_modules/mkdirp’ -> ‘/home/matthijs/.npm-global/lib/node_modules/vue-cli/node_modules/.mkdirp.DELETE’ npm ERR! at moveAway (/usr/lib/node_modules/npm/lib/install/action/finalize.js:38:5) npm ERR! at destStatted (/usr/lib/node_modules/npm/lib/install/action/finalize.js:27:7) npm ERR! at FSReqWrap.oncomplete (fs.js:123:15) npm ERR! npm ERR! Error: EACCES: permission denied, rename ‘/home/matthijs/.npm-global/lib/node_modules/vue-cli/node_modules/mkdirp’ -> ‘/home/matthijs/.npm-global/lib/node_modules/vue-cli/node_modules/.mkdirp.DELETE’ npm ERR! at Error (native) parent: ‘vue-cli’ } 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! /home/matthijs/npm-debug.log npm ERR! code 1

Running it as root does not help, the same error comes up. I have npm global packages set up in my home folder, so root is not necessary. Gulp, for instance installed and works fine without sudo.

  • Your Windows build number rs_prerelease 14965

  • Steps / All commands required to reproduce the error from a brand new installation $ npm install -g vue-cli

  • Required packages and commands to install nodejs 6.9.1, npm 3.10.8

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 17

Most upvoted comments

Not sure if that’s the right thing to do, but a sudo chown -R $(whoami) /mnt/c/Users/edjroot seems to have solved the problem.

this is what i experienced, i am quite sure this is not really a permission issue

engshun@SHUN-PC:~$ uname -a
Linux SHUN-PC 4.4.0-19041-Microsoft #488-Microsoft Mon Sep 01 13:43:00 PST 2020 x86_64 x86_64 x86_64 GNU/Linux
engshun@SHUN-PC:~$ sudo npm install -g npm
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/string-width
npm ERR! dest /usr/lib/node_modules/.staging/string-width-5ef4a6e1
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/string-width' -> '/usr/lib/node_modules/.staging/string-width-5ef4a6e1'
npm ERR!  [OperationalError: EACCES: permission denied, rename '/usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/string-width' -> '/usr/lib/node_modules/.staging/string-width-5ef4a6e1'] {
npm ERR!   cause: [Error: EACCES: permission denied, rename '/usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/string-width' -> '/usr/lib/node_modules/.staging/string-width-5ef4a6e1'] {
npm ERR!     errno: -13,
npm ERR!     code: 'EACCES',
npm ERR!     syscall: 'rename',
npm ERR!     path: '/usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/string-width',
npm ERR!     dest: '/usr/lib/node_modules/.staging/string-width-5ef4a6e1'
npm ERR!   },
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'rename',
npm ERR!   path: '/usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/string-width',
npm ERR!   dest: '/usr/lib/node_modules/.staging/string-width-5ef4a6e1'
npm ERR! }
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.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/engshun/.npm/_logs/2021-02-07T04_29_27_923Z-debug.log

I’ve got the same error and managed to solve it following the migration to WSL 2.

First make sure you have hyper virtualization activated and available. You will need to first make sure it is turned on in the BIOS (under advanced settings for CPU) and then activate it in Windows 10

Once you have done that, you can start update to WSL 2 following this guide Basically you will do if you use Ubuntu 20.04

wsl --set-version Ubuntu-20.04 2

The Microsoft doc also helps : https://docs.microsoft.com/en-us/windows/wsl/install-win10#update-to-wsl-2

After doing the following no more code: 'EACCES' or errno: -13 !

Hope it helps.

P.S, as It also helps resolve this issue : #2097 is closed. I referenced it here in order for other to help resolve this issue.

i know this issue is not exists in wsl2 but there is a reason i am not using it, so i will just leave it like this

I’ve got the same error and managed to solve it following the migration to WSL 2.

First make sure you have hyper virtualization activated and available. You will need to first make sure it is turned on in the BIOS (under advanced settings for CPU) and then activate it in Windows 10

Once you have done that, you can start update to WSL 2 following this guide Basically you will do if you use Ubuntu 20.04

wsl --set-version Ubuntu-20.04 2

The Microsoft doc also helps : https://docs.microsoft.com/en-us/windows/wsl/install-win10#update-to-wsl-2

After doing the following no more code: 'EACCES' or errno: -13 !

Hope it helps.

P.S, as It also helps resolve this issue : https://github.com/microsoft/WSL/issues/2097 is closed. I referenced it here in order for other to help resolve this issue.

I also get this error from time to time when installing non-global packages. Running the install command twice usually fix this.

I have had the same problem and the @edjroot 's solution save my life!! Thank you very much man.

You should use sudo. Try sudo npm install -g vue-cli