WSL: 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 fsevents@1.1.1: 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
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Reactions: 35
- Comments: 87 (1 by maintainers)
I can also confirm that simply closing VSCode (or whatever editor/ide one might have that working folder opened in) allows for
npm installto 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
Still seeing this today.
I solved this by mounting C:/ with default permissions bound to my user instead of root. I followed the guide here: https://devblogs.microsoft.com/commandline/chmod-chown-wsl-improvements/
This mounts all files on the C drive as my user instead of root. Therefore sudo is not needed to run
npm iI can also confirm that closing VSCode (the native linux one running in WSL) allows the npm install to run without error and I’m running Windows build 17074.rs_prerelease_flt.180116-1539.
Side note, mine is not a global install just a local install.
Giving up on WSL for now 😦 Every time I get this error I have to reboot and that’s not very productive.
This thread started May 2018 and the issue still persists today.
Issue here too. Closing VSCode and redoing npm install from WSL directory went ok. Not ideal at all and I hope the team can find a solution to this. It interrupts the normal workflow with Node.
Also here to report having the same problem with VSCode using WSL. Any time VSCode is open with WSL an error occurs (ENOENT no such file or directory, rename…)
I’ve already added node_modules to file.exclude and watcher.exclude settings but the issue still occurs. OS Build : 18362.175 VSCode : 1.36.0
@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 <package>
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.
I appreciate the work you’re doing here. I just wanted to leave a signpost for future travelers who, like me, found this issue first, and were frustrated to discover it was closed, despite the steady stream of “me too” replies. The root cause seems to be under investigation, even if this higher level issue is closed.
Upon closer inspection, I see you provided links to some potentially related issues earlier in the thread. I missed those links on my first quick read through.
I meet this bug too with the newest npm(6.9.0). So I tried
sudo, and it works Emmm, just try this.Now, It should be works.
The status of this issue has been covered already. There are three possibilities commonly observed with
npmEACCESproblems. (a) #1529 (b) tag linux-behavior, usually from people new tonpm, and a non-zero but nevertheless epsilon probability © something new. If you believe you fall into category ©, then feel encouraged to open a new issue: ensuring it includes CLI repro steps that can be cut-and-paste verbatim from a clean-install into Ubuntu 18.04 on Real Linux in a VM and a clean Ubuntu 18.04 from the Store on Windows/WSL 1809, that clearly demonstrates in thestracelog it isn’t #1529.[ed, clarification] I suspect it would take an issue submitter the better part of a day’s effort to demonstrate theoretic © - because, narrowing the
npmsequence to something reproducible and actionable would be a nontrivial exercise, even in the (very small but nonzero) chance it was possible to demonstrate a problem that was novel. Bonne chance.Is there a way to run npm install on WSL without closing my editor? It is kind of annoying to have to close VSCode every time I have to run npm install 😦
I was not able to fix this problem with any of the above solutions (unsafe-perm, prefix, etc.). I do believe the issue is with open filehandles. I installed yarn and it worked straight away.
It is not. #1956 #966 #2836 etc etc aka #1529
So I ended up having the same issue, and realized I had two conflicting NPM versions on my computer.
where npmwill reveal if you have multiple npm’s installed.The cause of the issue was doing both
apt install nodejsandapt install npmwhen in reality nodejs package already came with npm. Removing the npm and using the default npm with the nodejs package fixed it for me.I’m having the same issue on WSL 2, the project folder is in my home directory, not a mounted NTFS partition. Not even restarts or using sudo help.
Edit: never mind, turns out my distro was on WSL 1. Also, seems like this was caused by the VS Code file watcher in my case. https://code.visualstudio.com/docs/remote/wsl#_i-see-eaccess-permission-denied-error-trying-to-rename-a-folder-in-the-open-workspace
Nope, it does not help.
How I got it to work : Earlier, I opened VSCode- Remote WSL(via the extension button) which seems to be the cause. Now I open VSCode, and access the Linux File System through
\\wsl$\home\username\(GUI - Network tab in This PC) and the Ubuntu terminal.@therealkenc
OS Build : 18362.175 The problem still persists.
Just throwing a contribution in since I hit this issue myself. I had sublime text open on the directory I was attempting to install to. Adding “node_modules” to the excluded directories and no problems since. Perhaps if you’ve got any editors looking at the directory, close them or add node modules to the exclude list?
For me, the following 2 solutions worked -
One thing you might want to try is disable the vscode’s file watcher on node_modules.
We have an older project that still uses gulp and part of the gulp serve:dev command was to rm -rf ./dist
since vscode was watching ./dist it failed something like:
When I read this answer I realized that this issue only happened to me after I open VSCode from WSL. Reboot Windows worked fine for me, thanks @suprsidr. I think it could be a problem with the WSL extension of VSCode. Note: Closing VSCode didn’t work for me
I do encounter this issue as well from time to time, it happens often with large
node_modulesfolders. The only thing that helps for me is to remove the folder entirely and runnpm installagain. This is quite a hassle as it makes installation unpredictable.I’ve got another behavior/observation that further strengthens my theory about rapid/lagged I/O. My Node.js app (running in WSL directly, or in Docker via a folder-bind, but NOT if it’s running inside Docker storage) regularly has I/O errors (files not found, files can’t be deleted/moved/renamed). I’ve been building node-cloudfs-drive for a few months and have discovered that Google has offloaded handling of their touchy API (touchy in terms queuing/quota/load) and so I’ve had to add throttling/retries and it occurred to me to test my IO theory by wrapping my I/O calls with the same
retrylibrary.The result is no more unexpected I/O errors. What there is gets handled by retry transparently and never fails the retries, so I don’t see the errors. This is exactly what my theory predicted.
To me it appears that WSL is telling services that I/O is handled, but it is not in reality. It feels like a failing, write-back cache, but it’s never far from being available (I suspect ms, but haven’t tested down below 50ms for my retries), more of a phase-difference 😃
Here’s what I’m doing with retry:
I found a temporary solution that worked for me. Is to close all open folders with directory in which node_modules is being present and all editors (Idea, VS Code etc.). Then just run bash.exe and
npm i.quoth: from two-digit #14 that was closed but remains unaddressed:
I am also facing same Issue with WSL Ubuntu in Windows v1709 (build 16299.15)
`npm ERR! Linux 4.4.0-43-Microsoft npm ERR! argv “/usr/bin/node” “/usr/bin/npm” “install” npm ERR! node v6.11.5 npm ERR! npm v3.10.10 npm ERR! path /mnt/d/Projects/v2/ui/node_modules/leek npm ERR! code ENOTEMPTY npm ERR! errno -39 npm ERR! syscall rename
npm ERR! ENOTEMPTY: directory not empty, rename ‘/mnt/d/Projects/v2/ui/node_modules/leek’ -> ‘/mnt/d/Projects/v2/ui/node_modules/.leek.DELETE’ npm ERR! npm ERR! If you need help, you may report this error at: npm ERR! https://github.com/npm/npm/issues
npm ERR! Please include the following file with any support request: npm ERR! /mnt/d/Projects/v2/ui/npm-debug.log`
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:
Intructions according to source:
+ terminal restart