Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPM global package install throws EACCES error #1375

Closed
mattixittam opened this issue Nov 16, 2016 · 17 comments
Closed

NPM global package install throws EACCES error #1375

mattixittam opened this issue Nov 16, 2016 · 17 comments

Comments

@mattixittam
Copy link

mattixittam commented Nov 16, 2016

  • 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

@aqcohen
Copy link

aqcohen commented Nov 17, 2016

Did you try this?

https://docs.npmjs.com/getting-started/fixing-npm-permissions

@mattixittam
Copy link
Author

Yup, option 2 is my setup. And it works for some global packages (without sudo), but not for this one.

@edjroot
Copy link

edjroot commented Jan 23, 2017

Same here. I was trying to install npm i -g standard and got npm WARN checkPermissions Missing write access to /usr/lib/node_modules and Error: EACCES: permission denied, access '/usr/lib/node_modules'. I followed the instructions in the link above and now I get the same error as OP.

@arcanis
Copy link

arcanis commented Jan 23, 2017

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

@edjroot
Copy link

edjroot commented Jan 25, 2017

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.

@iOSKida
Copy link

iOSKida commented Mar 22, 2018

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

@therealkenc
Copy link
Collaborator

therealkenc commented Mar 22, 2018

From the top:

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

This one was left uncategorised since 2016. In the interest of closure, as with iOSKida above, on 17627 I just tried:

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -   # node 8.10.0
sudo npm install -g vue-cli # vue-cli 2.9.3

It takes without incident. It is possible something in WSL was fixed along the way, but I can't finger a specific issue to dupe. It is also possible (I would say probable but we'll never know) this was #1529 and something changed in vue-cli or npm or node (and their dependencies) or a combination thereof. Don't read anything into the need-repro tag, it just can't be reproduced now; no doubt the OP was feeling the grief. But there was no strace in the original post to guess the fail, and no actionable today, so closing.

@manueltarga
Copy link

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

@jeansordes
Copy link

@htor
Copy link

htor commented May 7, 2019

@therealkenc please re-open - this is still an issue i only get inside wsl.
tried re-installing node+npm as suggested by npm. still getting EACESS error when trying install anything globally with the npm command using sudo or as the root user. the root user should be able to write to anywhere, so this is strange.
windows version: 1803 (OS Build 17134.706)
distro: debian stretch (stable)
node installed from: https://github.com/nodesource/distributions
i'm gonna upgrade to debian sid (unstable) and see if that changes anything.
update: nope, didn't change anything

@therealkenc
Copy link
Collaborator

this is still an issue

This is not. This didn't even make it out of need-repro.

@htor
Copy link

htor commented May 12, 2019

sure, i see that you failed to repro with vue-cli, but did you try installing another tool globally?
for instance these fail here:

npm install -g npm
npm install -g youtube-dl

for now i've settled on moving the global npm directory elsewhere as described in https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally. leaving this here for future visitors

@spreadpando
Copy link

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

wtf this worked like a charm

@borb
Copy link

borb commented Jan 5, 2020

This also happens repeatedly for me when installing project-local packages into node_modules; my permissions are correct, ownership is correct (find node_modules ! -uid $(id -u) finds nothing which isn't owned by me). Repeating the same operation usually makes it go away, but for installing packages with lots of subdependencies it's utterly infurating.

I have node 13.5.0 & npm 6.13.4.

% npm install --save bcrypt    
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /home/myuser/Source/myproject/node_modules/gauge
npm ERR! dest /home/myuser/Source/myproject/node_modules/.gauge.DELETE
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/home/myuser/Source/myproject/node_modules/gauge' -> '/home/myuser/Source/myproject/node_modules/.gauge.DELETE'
npm ERR!  [OperationalError: EACCES: permission denied, rename '/home/myuser/Source/myproject/node_modules/gauge' -> '/home/myuser/Source/myproject/node_modules/.gauge.DELETE'] {
npm ERR!   cause: [Error: EACCES: permission denied, rename '/home/myuser/Source/myproject/node_modules/gauge' -> '/home/myuser/Source/myproject/node_modules/.gauge.DELETE'] {
npm ERR!     errno: -13,
npm ERR!     code: 'EACCES',
npm ERR!     syscall: 'rename',
npm ERR!     path: '/home/myuser/Source/myproject/node_modules/gauge',
npm ERR!     dest: '/home/myuser/Source/myproject/node_modules/.gauge.DELETE'
npm ERR!   },
npm ERR!   stack: "Error: EACCES: permission denied, rename '/home/myuser/Source/myproject/node_modules/gauge' -> '/home/myuser/Source/myproject/node_modules/.gauge.DELETE'",
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'rename',
npm ERR!   path: '/home/myuser/Source/myproject/node_modules/gauge',
npm ERR!   dest: '/home/myuser/Source/myproject/node_modules/.gauge.DELETE',
npm ERR!   parent: 'myproject'
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/myuser/.npm/_logs/2020-01-05T22_06_01_899Z-debug.log

@eslym
Copy link

eslym commented Feb 7, 2021

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

@gabrielstuff
Copy link

gabrielstuff commented May 3, 2021

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.

@eslym
Copy link

eslym commented May 3, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests