WSL: Unable to install `acorn` npm package (inability to symlink on mounted drives)

Steps to reproduce:

  • Launch “Bash on Ubuntu on Windows” (note that it appears to use the ‘root’ user by default)
  • Install nodejs via: curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
  • sudo apt-get install -y nodejs
  • Try to install the acorn package via npm install acorn

You’ll get this message:

npm ERR! Linux 3.4.0+
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "acorn"
npm ERR! node v5.10.1
npm ERR! npm  v3.8.3
npm ERR! path ../acorn/bin/acorn
npm ERR! code EPERM
npm ERR! errno -1
npm ERR! syscall symlink

npm ERR! Error: EPERM: operation not permitted, symlink '../acorn/bin/acorn' -> '/mnt/r/path/node_modules/.bin/acorn'
npm ERR!     at Error (native)
npm ERR!  { [Error: EPERM: operation not permitted, symlink '../acorn/bin/acorn' -> '/mnt/r/path/node_modules/.bin/acorn']
npm ERR!   errno: -1,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'symlink',
npm ERR!   path: '../acorn/bin/acorn',
npm ERR!   dest: '/mnt/r/path/node_modules/.bin/acorn',
npm ERR!   parent: 'myproject' }
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!     /mnt/r/path/npm-debug.log

Not sure how to proceed as I’m already root with full permissions

UPDATE: For other nodejs developers finding this issue. Here is what I seem to have uncovered so far:

  • npm install -g {anything} doesn’t seem to work
  • npm install {anything} doesn’t seem to work if installing anywhere on /
  • npm install {some_packages} on /mnt/{something} sometimes doesn’t work depending on whether or not that package needs to create symlinks

About this issue

  • Original URL
  • State: closed
  • Created 11 years ago
  • Reactions: 24
  • Comments: 52 (8 by maintainers)

Most upvoted comments

try npm install acorn --no-bin-links https://docs.npmjs.com/misc/config#bin-links

Installing WSL2 should fix this issue, btw.

This issue happens again, please reopen it!

I ran into this issue while setting up a new Project with VSCode using the VSCode-remote functionality. I’m running an Ubuntu Linux VM in WSL for development work.

The comment from @Aymkdn was spot on - in my case it was an EBUSY, not an EACCES error, due to the fundamental ‘feature’ of NTFS - if a directory is in use by another application (in this case, VSCode), it cannot be modified or deleted. Acorn’s need to delete that one file threw everything out of whack. 😃

Remediation:

  • Close VS Code or anything also accessing the files you are working on
  • Have only the WSL terminal open
  • Install desired npm packages via terminal
  • Reopen VS Code/Editor/etc

Is the symlinks bug still present?

OS build :16299.192 Node: 9.4.0 Npm: 5.6.0

Output:

npm ERR! path ../nodemon/bin/nodemon.js
npm ERR! code Unknown system error -75
npm ERR! errno -75
npm ERR! syscall symlink
npm ERR! Unknown system error -75: Unknown system error -75, symlink '../nodemon/bin/nodemon.js' -> '
/mnt/d/workspace/affinity_v1/server/node_modules/.bin/nodemon'

I can install it with --no-bin-links

New build is out (14352). This should fix the issue in #313.

All known npm bugs are now fixed. Please report if anything else looks odd.

It appears, ln -s doesn’t work on the mounted drives, which is what’s causing the issue:

cd /mnt/c/Windows/Temp
touch a
ln -s a b
> ln: failed to create symbolic link ‘b’: Operation not permitted

me also facing this issue in WSL/Debian, node 10.2.1, npm 6.1.0, using nvm –no-bin-links flag is not helping

Same permission issue here.

I tried to create a simple symlink and it worked: aymeric@box:/mnt/c/Users/aymeric/Desktop$ ln -s /mnt/c/Users users

However I have difficulties to install packages, even with --no-bin-link flag :

npm ERR! path /mnt/c/Users/aymeric/Documents/PROJECTS/nodejs/Roadmap/node_modules/.static-eval.DELETE/node_modules/esprima
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall rename
npm ERR! Error: EACCES: permission denied, rename '/mnt/c/Users/aymeric/Documents/PROJECTS/nodejs/Roadmap/node_modules/.static-eval.DELETE/node_modules/esprima' -> '/mnt/c/Users/aymeric/Documents/PROJECTS/nodejs/Roadmap/node_modules/static-eval/node_modules/esprima'
npm ERR!  { [Error: EACCES: permission denied, rename '/mnt/c/Users/aymeric/Documents/PROJECTS/nodejs/Roadmap/node_modules/.static-eval.DELETE/node_modules/esprima' -> '/mnt/c/Users/aymeric/Documents/PROJECTS/nodejs/Roadmap/node_modules/static-eval/node_modules/esprima']
...

I have Windows 10 Enterprise, v1703, OS build 15063.540

Based on this other issue https://github.com/Microsoft/WSL/issues/14 I tried to close everything and I rebooted: and it worked! Looks like it’s effectively a EBUSY issue and not a EACCESS…

The resolution: close everything that could interact with the folder (like SublimeText and other stuff) to make it work.

Thanks

I was having a lot of npm errors after upgrading to Build 14352. So I did a full re-install of Bash For Windows (using these instructions: https://github.com/Microsoft/BashOnWindows/issues/4#issuecomment-206657867). Then after re-installing node (using these instructions https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions) I can confirm:

  • ✅ npm install acorn works in /tmp
  • ✅ sudo npm install -g acorn also works
  • ✅ npm install acorn also works in /mnt/*

Incredible work @russalex & team. I am now unblocked to do my day-to-day work using Bash On Windows! Closing issue!

New release (14342), time to comment here. Some good news and some bad news.

The good news:

  • npm install acorn on /mnt/* drives now installs
  • sudo npm install -g acorn also installs

Now the bad news.

  • Issue #313 looks to be breaking some npm packages (have not tested them all but know this is a bad bug). We have a fix inbound which we are planning on getting out on the next insider release. I have tried sudo npm install -g yo with the fix and it looked to install. Right now I believe this is the last of the npm blockers.

Ok, good news and bad news.

First the good news. Running through the steps on /tmp on one of our dev branches. Looks like there’s a fix inbound. This morning I was able to:

/tmp$ npm install acorn /tmp └── acorn@3.0.4

npm WARN enoent ENOENT: no such file or directory, open ‘/tmp/package.json’ npm WARN tmp No description npm WARN tmp No repository field. npm WARN tmp No README data npm WARN tmp No license field.

Bad news is that this does not work through /mnt/c. I’ll need to write a bug on that one.

The team is hard at work fixing bugs. Every build we put out should have visible improvements. Not certain when this one will hit the insider flight, but it is inbound.

Launching “Bash on Ubuntu on Windows” with “Run as administrator” did not help resolve this issue. The same error appears.

This is STILL an issue in 2022. Debian 12, 4.19.128-microsoft-standard #1 SMP Tue Jun 23 12:58:10 UTC 2020 x86_64 GNU/Linux, nodejs v16.15.1, npm 8.13.1.

I’m having the same issue.

I have the same issue. Is there any progress on this?

I am still having the same problem: cannot install acorn on a mounted usb drive (/mnt/d): is it supposed to be fixed?

I had to use the --no-bin-links trick otherwise I get the PERM error on symlink mentionned above.

And it won’t link any binaries in node_modules/.bin so it’s not a viable solution anyway.

I am so glad to hear you say that! This amazing GitHub community has been a huge part of how we have been able to iterate so quickly. Thank you from all of us!

@russalex Did some testing on Build 14328 and can confirm your notes

  • ✅ npm install acorn (and many other packages I tried) works in /tmp
  • 😢 npm install -g acorn still doesn’t work (same uv_pipe_open error)
  • 😢 npm install acorn still doesn’t work in /mnt/* (same symlink operation not permitted error)

Amazing work so far! And incredible community outreach from the Microsoft team working on this project. Really excited to try out the next public release.

#14

I believe these are related.

Actually, love the info. Thanks!

I’ll take this up to the devs tomorrow. The fact that you’re seeing the socket error makes me think that we have a bug someplace in our code. I’ll make certain it gets to the right place.