Closed
Description
While trying to install a packge with npm (for example lodash) it fails with error message:
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
I have tried to install it both with and without starting bash in administrator mode.
Reacted by Serkan Yerşen, Tiberiu Popescu, Val Kotlarov Hoffman, alexey2baranov, jaganjaan, Ken Schnall, Ayman safi, Jonas Hecht, Anthony Falcon, dr2009 and 136 more
Metadata
Metadata
Assignees
Labels
No labels
Activity
borovaka commentedon Apr 7, 2016
There is another wired thing about npm. When I try to install gulp globally I get:
jamesscholeyweb commentedon Apr 7, 2016
Same here. In fact if I try to update npm update -g npm@latest it attempts to copy lodash to the staging directory then throws the errror. Following this subsequent attempts to use npm are broken because it can no longer find lodash.
IMPORTANT
This really should be of utmost importance to the team. I for one was very excited and love how everything else works, but as you are adding this feature to windows with the intention of bringing web developers back to windows this needs fixing ASAP. This alone will stop me switching back to windows for web development and I'm sure it will be the same for many. It defeats the purpose of switching for me. Please please please fix.
jgchristopher commentedon Apr 8, 2016
Borislav Anchev (@borovaka) you can fix that error by allowing unsafe perms
npm config set unsafe-perm=truejamesscholeyweb commentedon Apr 8, 2016
Already tried. It bypasses the error but it still doesn't work. You will
get a permissions access error still or at least I did.
On Friday, April 8, 2016, John Christopher [email protected] wrote:
jgchristopher commentedon Apr 8, 2016
James Scholey (@jamesscholeyweb) right, I was able to get to your error after setting those perms. Otherwise I wasn't able to do anything.
jgchristopher commentedon Apr 8, 2016
This seems to be the underlying issue.
root@localhost:/usr/lib/node_modules/.staging# rename /usr/lib/node_modules/.staging/lodash-24c8c2f4 /usr/lib/node_modules/ember-cli/node_modules/babel-core/node_modules/lodash Bareword found where operator expected at (eval 1) line 1, near "24c8c2f4" (Missing operator before c8c2f4?) Unknown regexp modifier "/b" at (eval 1) line 1, at end of line syntax error at (eval 1) line 1, near "/."Sparticuz commentedon Apr 8, 2016
Related: MicrosoftDocs/WSL#26
It seems to be an issue with symlinks
jbaribeault commentedon Apr 8, 2016
Confirmed - this is totally related to the symlink issue.
jamespacileo commentedon Apr 11, 2016
Same here with
Here's the output
russalex commentedon Apr 12, 2016
This looks a lot like #3. We can keep the conversation going on there.
What I can say right now is that things are getting better (at least in non-mnt directories.). On my dev box I see:
It goes on from there. I should point out that I have not tried to actually use any of these, I have only installed them.
The team is hard at work getting stuff up and running. Npm is one of those things we're looking at now.
russalex commentedon Apr 14, 2016
Full disclosure here. Doing a little more testing on our internal build and finding that doing an "npm -g install " still throws the uv_pipe_open error, even when in ~/tmp.
We have someone looking into it.
mablae commentedon Apr 16, 2016
This seems also to be a valid issue when running npm in the new Windows 10 Bash
This solved it for me: https://gist.github.com/mattpodwysocki/4e6951fc93adae064a73ed0b2251d180
npm config set unsafe-perm trueI have no idea what it does however.
paseto commentedon Jul 4, 2016
If you are using with -g option, try to remove it.
bitcrazed commentedon Sep 23, 2016
FWIW, installing
lodashas per the OP's request works fine on build 14931!152 remaining items
daalvand commentedon Jul 11, 2021
I removed nodejs
sudo apt remove nodejsthen install nodejs current vestion from this link -> linkcurl -fsSL https://deb.nodesource.com/setup_current.x | sudo -E bash - sudo apt-get install -y nodejsit worked for me.
Tofandel commentedon Sep 22, 2021
I needed nodejs@14 but npm@latest and using n to switch to node 14 and then npm i -g npm@latest always resulted in the error
To solve the issue I installed the latest node using n
n latestand thenexport N_PRESERVE_NPM=1and againn 14which allowed me to have node v14 with an up to date npm without this weird errorhanzhangyu commentedon Nov 2, 2021
try set prefix out of c disk, such as
npm config set prefix '/mnt/f/npm/.npm-global'vivek0097 commentedon Dec 6, 2021
C:\Users\Dell>npm audit
npm audit report
ansi-regex >2.1.1 <5.0.1
Severity: moderate
Inefficient Regular Expression Complexity in chalk/ansi-regex - GHSA-93q8-gq69-wqmw
fix available via
npm audit fixnode_modules/npm/node_modules/cli-table3/node_modules/ansi-regex
node_modules/npm/node_modules/string-width/node_modules/ansi-regex
strip-ansi 4.0.0 - 5.2.0
Depends on vulnerable versions of ansi-regex
node_modules/npm/node_modules/string-width/node_modules/strip-ansi
string-width 2.1.0 - 4.1.0
Depends on vulnerable versions of strip-ansi
node_modules/npm/node_modules/string-width
3 moderate severity vulnerabilities
To address all issues, run:
npm audit fix
please any one can help to remove this error
iamsriranga commentedon Dec 21, 2021
As of now, I still faced the issue, closing vs code worked for me

vivek0097 commentedon Dec 22, 2021
I got error with 64 bit node 14,16,17v so i just uninstall this i am not able to create npx create-react-app, so i install 34 bit node latest version now i am able to create react-app my os is 64-bit.
akillingbeck89 commentedon Mar 16, 2022
Easiest solution here I found was to just use a node package manager (e.g. NVM), then global installs work fine at least
acongy commentedon Mar 16, 2022
jimbethancourt commentedon Apr 5, 2022
If you're using VS Code and find yourself getting this error message, close VS Code, run the desired command, and restart VS Code, as indicated in https://stackoverflow.com/questions/60853873/eaccess-error-when-installing-packages-on-wsl
gifflet commentedon May 11, 2022
If you installed node from apt-get, uninstall it completely and install it from NVM (Node Version Manager)
Uninstalling node (Ubuntu)
Update apt indexes
sudo apt update && sudo apt upgradeInstall NVM
Finally, install node and npm
acongy commentedon May 11, 2022
Jahongirhacking commentedon Jul 19, 2023
it says:
acongy commentedon Jul 19, 2023
Jahongirhacking commentedon Jul 19, 2023
Thanks it worked
PttRulez commentedon Oct 8, 2023
I have fixed my problem on mac by
sudo chown -R 501:20 "/Users/<my_username>/.npm"