MicrosoftDocs/WSL

npm install failing. Symlink problems?

Sparticuz opened this issue Β· 22 comments

npm ERR! Linux 3.4.0+
npm ERR! argv "/usr/bin/nodejs" "/usr/local/bin/npm" "install"
npm ERR! node v4.4.2
npm ERR! npm v3.8.5
npm ERR! path ../mime/cli.js
npm ERR! code EPERM
npm ERR! errno -1
npm ERR! syscall symlink

npm ERR! Error: EPERM: operation not permitted, symlink '../mime/cli.js' -> '/mnt/c/users/kyle/Documents/dev/listomaniapi/node_modules/.bin/mime'
npm ERR! at Error (native)
npm ERR! { [Error: EPERM: operation not permitted, symlink '../mime/cli.js' -> '/mnt/c/users/kyle/Documents/dev/listomaniapi/node_modules/.bin/mime']
npm ERR! errno: -1,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'symlink',
npm ERR! path: '../mime/cli.js',
npm ERR! dest: '/mnt/c/users/kyle/Documents/dev/listomaniapi/node_modules/.bin/mime',
npm ERR! parent: 'listomaniapi' }
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/c/users/kyle/Documents/dev/listomaniapi/npm-debug.log
npm ERR! code 1
root@localhost:~/dev/listomaniapi#

How did you try to install npm?

curl -sL https://deb.nodesource.com/setup_4.x | bash -
apt-get install nodejs

It's what is on nodejs.org's site

I've got a similar error when trying to install node and npm using nvm

same thing here.
A subdependency would love to make a symlink, and npm i fails because it can't.
We have symlinks in cmd through mklink /J so I don't really get why it's not possible through WSL yet.

npm ERR! Error: EPERM, symlink '../JSONStream/index.js'
npm ERR!  { [Error: EPERM, symlink '../JSONStream/index.js'] errno: 50, code: 'EPERM', path: '../JSONStream/index.js' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Linux 3.4.0+
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "i"
npm ERR! cwd /mnt/c/dev/scan-app
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.10
npm ERR! path ../JSONStream/index.js
npm ERR! code EPERM
npm ERR! errno 50
npm ERR! stack Error: EPERM, symlink '../JSONStream/index.js'

Using this I've had some luck installing some npm modules, but it still does have issues with permission errors whenever npm tries to rename a file.

INSTALL GLOBAL NPM PACKAGES
npm config set unsafe-perm true

CLEAN CACHE
npm cache clean

BYPASS SYMLINK ISSUES
npm install --no-bin-links

We have symlinks in cmd through mklink /J so I don't really get why it's not possible through WSL yet.

What's odd is the ln -s seems to work fine

In my tests, using pip, I was unable to create a virtualenv in my user folder.

root@localhost:/mnt/c/Users/sergi/demoubuntu# virtualenv py27
New python executable in py27/bin/python
Traceback (most recent call last):
  File "/usr/bin/virtualenv", line 3, in <module>
    virtualenv.main()
  File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 825, in main
    symlink=options.symlink)
  File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 985, in create_environment
    site_packages=site_packages, clear=clear, symlink=symlink))
  File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 1405, in install_python
    os.symlink(py_executable_base, full_pth)
OSError: [Errno 1] Operation not permitted

But was able to create inside Ubuntu filesystem

root@localhost:/home# virtualenv py27
New python executable in py27/bin/python
Installing setuptools, pip...done.

I think you've got the ln -s backwards, mine created just fine inside bash
lrwxrwxrwx 1 root root 31 Apr 7 01:24 dev -> /mnt/c/users/kyle/Documents/dev/

I was unable to use ln -s on /mnt/c/ (Operation not permitted) but it did work for me in the unix filesystem, for instance at ~/. a symlink created through mklink /J in cmd showed up in my bash, but it did look a bit strange (same for normal mklink):

$ l
ls: cannot access core: Input/output error
total 8.0K
d????????? ? ?    ?       ?            ? core/
-rwxrwxrwx 1 root root 1.2K Apr  7 15:54 index.js*
drwxrwxrwx 2 root root    0 Mar 31 16:14 subcomponents/
drwxrwxrwx 2 root root    0 Mar 31 16:14 viewcomponents/

thanks nerdofsteel for the suggestions. I too ran into the rename issue when trying to globally install a module. The no symlinks option seems to work like a charm for my local dependencies.

I think the problem for both virtualenv and npm is that those tools tries to create links to the Lxss filesystem.

root@localhost:/mnt/c/Users/sergi# ln -s /root .
ln: failed to create symbolic link β€˜./root’: Operation not permitted

It appears to be a problem with tar. It doesn't create symlinks ever. Every tool that I've tried to install that uses tar with symlinks fails.

More info here: microsoft/WSL#3

Just sudo npm install -g npm@5.3.0

$ npm install -g npm
C:\Users\aswathy\AppData\Roaming\npm\npx -> C:\Users\aswathy\AppData\Roaming\npm\node_modules\npm\bin\npx-cli.js
npm ERR! path C:\Users\aswathy\AppData\Roaming\npm\npm
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall open
npm ERR! Error: EPERM: operation not permitted, open 'C:\Users\aswathy\AppData\Roaming\npm\npm'
npm ERR! { Error: EPERM: operation not permitted, open 'C:\Users\aswathy\AppData\Roaming\npm\npm'
npm ERR! cause:
npm ERR! { Error: EPERM: operation not permitted, open 'C:\Users\aswathy\AppData\Roaming\npm\npm'
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'open',
npm ERR! path: 'C:\Users\aswathy\AppData\Roaming\npm\npm' },
npm ERR! stack: 'Error: EPERM: operation not permitted, open 'C:\Users\aswathy\AppData\Roaming\npm\npm'',
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'open',
npm ERR! path: 'C:\Users\aswathy\AppData\Roaming\npm\npm' }
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! C:\Users\aswathy\AppData\Roaming\npm-cache_logs\2018-01-16T10_46_38_513Z-debug.log

Using this I've had some luck installing some npm modules, but it still does have issues with permission errors whenever npm tries to rename a file.

INSTALL GLOBAL NPM PACKAGES
npm config set unsafe-perm true

CLEAN CACHE
npm cache clean

BYPASS SYMLINK ISSUES
npm install --no-bin-links

Thank. It's working:))

Using this I've had some luck installing some npm modules, but it still does have issues with permission errors whenever npm tries to rename a file.

INSTALL GLOBAL NPM PACKAGES
npm config set unsafe-perm true

CLEAN CACHE
npm cache clean

BYPASS SYMLINK ISSUES
npm install --no-bin-links

This worked like a charm! Thank you!

In my case I mount vfat into media so my ubuntu can't create symlinks into that mount point and raise this kind of error.

Fix the code if the deploy log in Netlify gives any error or warning and it will deploy.

Using this I've had some luck installing some npm modules, but it still does have issues with permission errors whenever npm tries to rename a file.

INSTALL GLOBAL NPM PACKAGES
npm config set unsafe-perm true

CLEAN CACHE
npm cache clean

BYPASS SYMLINK ISSUES
npm install --no-bin-links

Thanks it worked...!!

If you are using vs code, close it!

I ran into symlink issues with weird relative paths:
Error: EACCES: permission denied, symlink '../../../lib/node_modules/npm/man/man5/npm-shrinkwrap-json.5' -> '/usr/share/man/man5/npm-shrinkwrap-json.5'

And now npm is borked, as the rollback failed...

INSTALL GLOBAL NPM PACKAGES
npm config set unsafe-perm true

CLEAN CACHE
npm cache clean

BYPASS SYMLINK ISSUES
npm install --no-bin-links

It's working... perfect