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
Did you try this?
https://docs.npmjs.com/getting-started/fixing-npm-permissions
Not sure if that’s the right thing to do, but a
sudo chown -R $(whoami) /mnt/c/Users/edjrootseems to have solved the problem.this is what i experienced, i am quite sure this is not really a permission 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
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'orerrno: -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