Skip to content

Unable to install acorn npm package (inability to symlink on mounted drives) #3

Closed

Description

@EvHaus

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

Activity

  1. mizzle-mo commented on Apr 7, 2016

    @mizzle-mo

    Did you run the bash window as administrator in Windows? My very limited understanding is that in order for you to actually have elevated permissions to the underlying file system (and probably other stuff) you need to open the window elevated.

  2. EvHaus commented on Apr 7, 2016

    @EvHaus
    Author

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

  3. EvHaus commented on Apr 7, 2016

    @EvHaus
    Author

    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
    
  4. changed the title [-]Unable to install `acorn` npm package[/-] [+]Unable to install `acorn` npm package (inability to symlink on mounted drives)[/+] on Apr 7, 2016
  5. russalex commented on Apr 7, 2016

    @russalex
    Contributor

    Before going into possible solutions, I should point out that there are some issues with npm not related to symlinks. I have not tried acorn but will make certain this is one of our test.

    I should also point out that we have added a little bit about the filesystem here: https://msdn.microsoft.com/en-us/commandline/wsl/faq.

    That said, are you able to install acorn someplace under '/'?

  6. EvHaus commented on Apr 7, 2016

    @EvHaus
    Author

    That said, are you able to install acorn someplace under '/'?

    No. This works:

    cd /tmp
    touch a
    ln -s a b
    

    But this doesn't:

    root@localhost:/tmp# npm install acorn
    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.
    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 /tmp/node_modules/.staging/acorn-baee3507
    npm ERR! code EACCES
    npm ERR! errno -13
    npm ERR! syscall rename
    
    npm ERR! Error: EACCES: permission denied, rename '/tmp/node_modules/.staging/acorn-baee3507' -> '/tmp/node_modules/acorn'
    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 '/tmp/node_modules/.staging/acorn-baee3507' -> '/tmp/node_modules/acorn'
    npm ERR!     at Error (native)
    npm ERR!  [Error: EACCES: permission denied, rename '/tmp/node_modules/.staging/acorn-baee3507' -> '/tmp/node_modules/acorn']
    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!     /tmp/npm-debug.log
    

    EDIT: But I'm actually unable to install anything in /. All npm packages seem to give that same error message. Tried in /tmp as well as /home.

    Furthermore, trying to install a package globally returns an entirely new error:

    root@localhost:/home# npm install -g acorn
    Error: could not get uid/gid
    net.js:135
        this._handle.open(options.fd);
                     ^
    
    Error: EINVAL: invalid argument, uv_pipe_open
        at Error (native)
        at new Socket (net.js:135:18)
        at createWritableStdioStream (internal/process/stdio.js:142:16)
        at process.stdout (internal/process/stdio.js:10:14)
        at console.js:99:37
        at NativeModule.compile (node.js:395:5)
        at Function.NativeModule.require (node.js:340:18)
        at node.js:223:27
        at Object.<anonymous> (/usr/lib/node_modules/npm/node_modules/uid-number/get-uid-gid.js:16:1)
        at Module._compile (module.js:413:34)
    
        at /usr/lib/node_modules/npm/node_modules/uid-number/uid-number.js:37:16
        at ChildProcess.exithandler (child_process.js:209:5)
        at emitTwo (events.js:100:13)
        at ChildProcess.emit (events.js:185:7)
        at maybeClose (internal/child_process.js:850:16)
        at Socket.<anonymous> (internal/child_process.js:323:11)
        at emitOne (events.js:90:13)
        at Socket.emit (events.js:182:7)
        at Pipe._onclose (net.js:475:12)
    

    Sorry for all the error messages, just trying to post as much information for you guys as possible.

  7. russalex commented on Apr 7, 2016

    @russalex
    Contributor

    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.

  8. jokeyrhyme commented on Apr 7, 2016

    @jokeyrhyme

    Related to #6 and/or #9 ?

  9. mizzle-mo commented on Apr 7, 2016

    @mizzle-mo

    Russ Alexander (@russalex) This could be an issue with running the command as root. I was getting the same stack and the same "could not get uid/gid" running:

    npm install npm -g 
    

    I found these switches --user and --unsafe-perm

    unsafe-perm
    • Default: false if running as root, true otherwise
    • Type: Boolean

    Set to true to suppress the UID/GID switching when running package
    scripts. If set explicitly to false, then installing as a non-root user
    will fail.

    user
    • Default: "nobody"
    • Type: String or Number

    The UID to set to when running package scripts as root.

    When I executed:

    npm --user root --unsafe-perm true install npm -g
    

    It gets all the way to the end and fails.

    I tried again with a few different accounts existing and non-existing. It always makes it to the end and fails with this:

    root@localhost:~# npm --user sync --unsafe-perm true install npm -g
    - async-some@1.0.2 node_modules/npm/node_modules/async-some
    npm ERR! Linux 3.4.0+
    npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "--user" "sync" "--unsafe-perm" "true" "install" "npm" "-g"
    npm ERR! node v5.10.1
    npm ERR! npm  v3.8.3
    npm ERR! path /usr/lib/node_modules/npm
    npm ERR! code EACCES
    npm ERR! errno -13
    npm ERR! syscall rename
    
    npm ERR! Error: EACCES: permission denied, rename '/usr/lib/node_modules/npm' -> '/usr/lib/node_modules/.npm.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:82:15)
    npm ERR!
    npm ERR! Error: EACCES: permission denied, rename '/usr/lib/node_modules/npm' -> '/usr/lib/node_modules/.npm.DELETE'
    npm ERR!     at Error (native)
    npm ERR!  [Error: EACCES: permission denied, rename '/usr/lib/node_modules/npm' -> '/usr/lib/node_modules/.npm.DELETE']
    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/npm-debug.log
    

    I've got to call it a night, but I will try to look into it more tomorrow. Hopefully someone will have a workaround by then.

  10. russalex commented on Apr 7, 2016

    @russalex
    Contributor

    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.

  11. EvHaus commented on Apr 7, 2016

    @EvHaus
    Author

    Russ Alexander (@russalex) Thanks for the update! When files are written to / where do they actually go? Somewhere on the C: partition? Will files written to / disappear if Bash on Windows is uninstalled?

  12. jgchristopher commented on Apr 8, 2016

    @jgchristopher

    #14

    I believe these are related.

  13. mickeyinfoshan commented on Apr 11, 2016

    @mickeyinfoshan

    @Buck-Rawgers I got the same issue even --user root is used and run my bash as Administrator. Any ideas?

    npm ERR! Linux 3.4.0+
    npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "--user" "sync" "--unsafe-perm" "true" "install" "npm" "-g"
    npm ERR! node v5.10.1
    npm ERR! npm  v3.8.3
    npm ERR! path /usr/lib/node_modules/npm
    npm ERR! code EACCES
    npm ERR! errno -13
    npm ERR! syscall rename
    
    npm ERR! Error: EACCES: permission denied, rename '/usr/lib/node_modules/npm' -> '/usr/lib/node_modules/.npm.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:82:15)
    npm ERR!
    npm ERR! Error: EACCES: permission denied, rename '/usr/lib/node_modules/npm' -> '/usr/lib/node_modules/.npm.DELETE'
    npm ERR!     at Error (native)
    npm ERR!  [Error: EACCES: permission denied, rename '/usr/lib/node_modules/npm' -> '/usr/lib/node_modules/.npm.DELETE']
    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/npm-debug.log
    
  14. jgchristopher commented on Apr 11, 2016

    @jgchristopher

    @Buck-Rawgers until a update comes out fixing symlinks, there isn't much to do at this point.

  15. trevren11 commented on Apr 11, 2016

    @trevren11

    @EvNaverniouk go to %LOCALAPPDATA%\lxss\root and you will find the files that you are looking for (if I understood the first part of your most recent question).

  16. 27 remaining items

  17. Aymkdn commented on Aug 21, 2018

    @Aymkdn

    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 #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

  18. warpdesign commented on Sep 28, 2018

    @warpdesign

    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.

  19. ramonakira commented on Oct 20, 2018

    @ramonakira

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

  20. EricLambrecht commented on Jan 20, 2019

    @EricLambrecht

    I'm having the same issue.

  21. nikoinist commented on Mar 31, 2019

    @nikoinist

    For anyone having this issue with docker on windows, using the windows container solves this issue with symlinks.

  22. jsonMartin commented on Apr 23, 2019

    @jsonMartin

    Same issue, using npm directly on windows 10 installing acorn

  23. mrvdot commented on May 29, 2019

    @mrvdot

    I ran into the same issue on /mnt/d which is just a separate partition on my main hard-drive. Wondering could it be because it's formatted as exFAT (for better interoperability with native linux)? Perhaps symlinks only work in WSL on NTFS drives?

  24. mfilkov commented on Aug 7, 2019

    @mfilkov

    I also struggled with this for a while. It turned out that, indeed, exFAT doesn't support symlinks. I reformatted the partition to NTFS and it all works without a hitch ever since.

  25. madewithsalt commented on Sep 8, 2019

    @madewithsalt

    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 Aymeric (@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
  26. maixuanhan commented on Jan 1, 2020

    @maixuanhan

    This issue happens again, please reopen it!

  27. kaosaxis commented on Jan 3, 2020

    @kaosaxis

    Just ran into this error as well.

  28. slikts commented on Jan 3, 2020

    @slikts

    Probably the same issue as #1529.

  29. fatso83 commented on Mar 11, 2020

    @fatso83

    Installing WSL2 should fix this issue, btw.

  30. jerry-santana commented on Mar 21, 2020

    @jerry-santana

    I'm still having this issue! Did anyone fixed it?

  31. kleinesfilmroellchen commented on Jul 2, 2022

    @kleinesfilmroellchen

    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.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions