NPM Install - Rename Error
Windows Build
Microsoft Windows [Version 10.0.16193.1001]
Cause
Running npm install against a package.json and/or a single install (typescript or tslint).
Problem
TL;DR: Appears that #14 issue has returned.
On two different computers with the same build, npm has fails to installed packages due npm not able to moving it from node_modules/.staging/ to node_modules/. It's not limited to specific module. The real catch is, if I reboot the system and try again, the issue is resolved. In the last build, when this happen I would closed all editor windows and kill any running conhost, cmd, and bash process then retry with mostly success. Now the issue see to be more frequent and system must be rebooted to resolve.
NPM Error Example
brian@PC-Main:/mnt/c/Users/Brian/OneDrive/Development/GitHub/testdouble.js$ npm install tslint --save-dev
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! path /mnt/c/Users/Brian/OneDrive/Development/GitHub/testdouble.js/node_modules/.staging/tslint-07584f89
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall rename
npm ERR! Error: EACCES: permission denied, rename '/mnt/c/Users/Brian/OneDrive/Development/GitHub/testdouble.js/node_modules/.staging/tslint-07584f89' -> '/mnt/c/Users/Brian/OneDrive/Development/GitHub/testdouble.js/node_module
s/tslint'
npm ERR! { Error: EACCES: permission denied, rename '/mnt/c/Users/Brian/OneDrive/Development/GitHub/testdouble.js/node_modules/.staging/tslint-07584f89' -> '/mnt/c/Users/Brian/OneDrive/Development/GitHub/testdouble.js/node_mod
ules/tslint'
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/mnt/c/Users/Brian/OneDrive/Development/GitHub/testdouble.js/node_modules/.staging/tslint-07584f89',
npm ERR! dest: '/mnt/c/Users/Brian/OneDrive/Development/GitHub/testdouble.js/node_modules/tslint',
npm ERR! parent: 'testdouble' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/brian/.npm/_logs/2017-05-13T00_55_06_467Z-debug.log
Strace
@russalex Take a look, please? This is in build 15063. I've seen this happen when running an "npm install" on an actual source tree that's pulling in quite a few packages. npm will install packages, and will fail some of the way through with EACCESS during rename. Race condition maybe, or as someone suggested, a "timeout" on forked process?
Please let me know whether you'd like an example. I can point you towards the github of the source tree that caused this in my environment.
Race condition maybe, or as someone suggested, a "timeout" on forked process?
My thoughts, exactly.
Although I have adjusted my development workflow to reduce the need to call npm install, I have not seen this issue occur on Build 16199. I am not sure if it is actually resolved or if I have not seen it because I am not calling npm install as often.
Spoke too soon. Issue occur again while running npm upgrade against package.json. Had to execute the command several times before it finished updating all the packages.
@sgtoj , this appears resolved in build 16215. Can you confirm?
Thanks for your post and sorry for the delay. I tried this on build 16215 and ended up with the message ENOENT: no such file or directory, open '/home/wsl/package.json'. That does not look like a repro of the issue. What step am I missing?

@sunilmut The issue discussed here happens when pulling in a whole bunch of packages that are part of a javascript project. You can use 'npm init' to be walked through creating a dummy package.json if you want to test just installing one package, see https://nodesource.com/blog/your-first-nodejs-package/
If you want to see 'npm install' grabbing a whole bunch of packages, you could fork a javascript project. The one I'm using for testing is at https://github.com/symposion/roll20-shaped-scripts . Fork that, clone it locally, and have at it with 'npm install' (note that this package relies on a private repo for 'npm test' to work, it's normal for 'npm test' to fail out of the box on this one).
I can also confirm that simply closing VSCode (or whatever editor/ide one might have that working folder opened in) allows for npm install to run properly, without any errors. I didn't have to restart anything else.
But this is still a bummer... Having to close the editor means we can't use bash through the integrated terminal that VSCode offers.
Windows 10 Pro, Version 1703, Build 15063.413 Ubuntu: 16.04.2 LTS
@sunilmut I just had this happen to me again in 16232. Running 'npm install' a second time, it completed. There's definitely some form of timeout or race condition here.
Getting this error as soon as i try to update any sort of package, or install a package which seems to have an already existing dependency installed.
I have tried the following:
- Tried different versions of node/npm through nvm
- Turned off third party firewall
- Installation through curl from nodejs website
- Clean install of WSL itself
Each time the npm update fails, npm then in return gets removed and I have to reinstall the whole node version to get npm back
npm ERR! Linux 4.4.0-43-Microsoft
npm ERR! argv "/home/felixnorden/.nvm/versions/node/v6.11.2/bin/node" "/home/felixnorden/.nvm/versions
/node/v6.11.2/bin/npm" "i" "-g" "npm@latest"
npm ERR! node v6.11.2
npm ERR! npm v3.10.10
npm ERR! path /home/felixnorden/.nvm/versions/node/v6.11.2/lib/node_modules/.staging/sshpk-0bf1fa9c
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/home/felixnorden/.nvm/versions/node/v6.11.
2/lib/node_modules/.staging/sshpk-0bf1fa9c' -> '/home/felixnorden/.nvm/versions/node/v6.11.2/lib/node_
modules/npm/node_modules/request/node_modules/http-signature/node_modules/sshpk'
npm ERR! enoent ENOENT: no such file or directory, rename '/home/felixnorden/.nvm/versions/node/v6.11.
2/lib/node_modules/.staging/sshpk-0bf1fa9c' -> '/home/felixnorden/.nvm/versions/node/v6.11.2/lib/node_
modules/npm/node_modules/request/node_modules/http-signature/node_modules/sshpk'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! Please include the following file with any support request:
npm ERR! /mnt/c/Users/Felix/npm-debug.log
npm ERR! code 1
@MrCroft The problem for me is that it happens even among the global node modules. I also tried to update the files locally in the global modules folder, as suggested by the accepted answer at stackoverflow, but it doesn't work... At least that may be a good thing, compared to the odd behavior you're experiencing with the editor/ide?
@felixnorden Have you tried this in Insider build 16251? I just tested again, opening two bash windows and running npm install on two separate projects at the same time to really stress the system - and it worked without a hitch.
Since the issue is intermittent, I think 16251 needs more testing before we can say "this appears to be fixed now."
@yorickdowne No, I'm on build 15063.502. Maybe I'll try that and I'll get back with the results!
@felixnorden Be sure to test on a separate install / partition. Insider builds can be temperamental.
@yorickdowne After the update things seem to be working fine. I've tried to do multiple clean installs of different node versions, updating both npm and other global packages and only did it fail once (the first time), which instead gave an ENOENT: No such file or directory, open error instead of rename, so I guess I'm safe for now. Thanks for the help!
So I ended up having the same issue, and realized I had two conflicting NPM versions on my computer.
where npm will reveal if you have multiple npm's installed.
The cause of the issue was doing both apt install nodejs and apt install npm when in reality nodejs package already came with npm. Removing the npm and using the default npm with the nodejs package fixed it for me.
@kaiwah wow, never tried that. Didn't realize you could have 2 versions of npm at the same time :)
To update npm I just simply run npm install -g npm - not saying that you wanted to update npm, I understood that you just didn't realize it came with nodejs.
Plus... I use nvm to manage different node versions. Not that I need multiple versions, but it makes it so easy to install node, set default version to be used (alias default) etc.
I come from windows, so... Installing stuff through command line still seems very weird for me :) actually, still on windows... Just using "bash on Ubuntu on Windows". Starting to like it.
Sent from my Samsung SM-G950F using FastHub
@MrCroft yup! I use NVM now as well to swap between node versions. But when I first installed, I assumed apt install npm would automatically place the same bin as the one within nodejs package but it didn't -- but it definitely caused a problem. So when I tried to update npm, it was updating a different npm than the one that was used by default.
And I love WSL, but unfortunately it seems I will be going back to either Ubuntu native or GitBash as the WSL file system is too slow doubling my build times.
I'm new to npm, so I don't know how much of a solution this is for a more experienced user, but it works for me.
The mensioned problem:
...
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall rename
...
Intructions according to source:
mkdir ~/.npm-new
npm config set prefix '~/.npm-new'
export PATH=~/.npm-new/bin:$PATH
source ~/.profile
+ terminal restart
@bart5, those instructions are for installing global npm packages without the need for sudo, by pointing npm at a local user directory for global files.
I'd just as soon run sudo npm -g install
The issue discusses here is for local, not global, npm install, only happens when a large amount of packages are being installed, and appears to be some kind of timeout or race condition.
And it appears it's fixed in all the current Insider builds.
This may be resolved? I haven't had any issues for awhile.
Edit: Using Windows 10 Insider's Build 16275