52

I have Ubuntu 12.10 running as a VMware guest on my Windows 8 host.

I have shared a folder on my Windows 8 Host and it is mounted in the Ubuntu guest on startup using this entry in fstab:

//myhost/work /work cifs credentials=/home/user/.smbcredentials,noserverino,nounix,uid=user,gid=user,file_mode=0777,dir_mode=0777 0 0 

The share works fine and is able to be served by a webserver such as nginx.

However, there seems to be issues when I install node.js packages using npm, I get a bunch of errors like this:

user@ubuntu:/work/test$ sudo npm install grunt
npm http GET https://registry.npmjs.org/grunt
npm http 304 https://registry.npmjs.org/grunt
...
npm ERR! error rolling back Error: ENOTEMPTY, rmdir '/work/test/node_modules/grunt/node_modules/lodash'
npm ERR! error rolling back  [email protected] { [Error: ENOTEMPTY, rmdir '/work/test/node_modules/grunt/node_modules/lodash']
npm ERR! error rolling back   errno: 53,
npm ERR! error rolling back   code: 'ENOTEMPTY',
npm ERR! error rolling back   path: '/work/test/node_modules/grunt/node_modules/lodash' }
npm ERR! Error: UNKNOWN, symlink '../which/bin/which'
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>

npm ERR! System Linux 3.5.0-26-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "grunt"
npm ERR! cwd /work/test
npm ERR! node -v v0.10.0
npm ERR! npm -v 1.2.14
npm ERR! path ../which/bin/which
npm ERR! code UNKNOWN
npm ERR! errno -1
npm ERR! Error: ENOENT, chmod '/work/test/node_modules/grunt/node_modules/findup-sync/test/fixtures/aaa.txt'
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>

npm ERR! System Linux 3.5.0-26-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "grunt"
npm ERR! cwd /work/test
npm ERR! node -v v0.10.0
npm ERR! npm -v 1.2.14
npm ERR! path /work/test/node_modules/grunt/node_modules/findup-sync/test/fixtures/aaa.txt
npm ERR! fstream_path /work/test/node_modules/grunt/node_modules/findup-sync/test/fixtures/aaa.txt
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! fstream_finish_call chmod
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack /usr/lib/node_modules/npm/node_modules/fstream/lib/writer.js:305:19
npm ERR! fstream_stack Object.oncomplete (fs.js:93:15)
npm ERR! Error: ENOENT, lstat '/work/test/node_modules/grunt/node_modules/minimatch/test/basic.js'
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>

npm ERR! System Linux 3.5.0-26-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "grunt"
npm ERR! cwd /work/test
npm ERR! node -v v0.10.0
npm ERR! npm -v 1.2.14
npm ERR! path /work/test/node_modules/grunt/node_modules/minimatch/test/basic.js
npm ERR! fstream_path /work/test/node_modules/grunt/node_modules/minimatch/test/basic.js
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack /usr/lib/node_modules/npm/node_modules/fstream/lib/writer.js:284:26
npm ERR! fstream_stack Object.oncomplete (fs.js:93:15)
npm ERR! Error: ENOENT, lstat '/work/test/node_modules/grunt/node_modules/glob/test/00-setup.js'
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>
...
npm ERR! not ok code 0
user@ubuntu:/work/test$ 

What could be causing this problem? From the command line, I can chmod, rmdir among other things using sudo without any issues.

6 Answers 6

120

Running with --no-bin-links fixed it for me:

npm install --no-bin-links

--no-bin-links tells npm to not create any symbolic links.

Occasionally, for some packages that create symlinks even with the --no-bin-links directive, or in the case where using this directive causes other errors, you can remove the symlinks from the package(s) that is showing error with the command:

npm unlink <package>

There is definitely no way to translate symlinks to a Windows share.

7
  • 16
    I wish I could upvote you 200 more times. This makes it possible to use Vagrant on windows.
    – Clint
    Aug 1, 2013 at 20:37
  • 1
    npm install --no-bin-link also works.
    – JamieJag
    Oct 16, 2013 at 13:10
  • 2
    Great answer! But is there a way to make this work with the "devDependencies" of a package.json file from Grunt? That would be awesome :)
    – Jelmer
    May 8, 2014 at 19:36
  • 1
    Thank you! Vagrant should put this in their official documentation for Windows. All my points are belong to you.
    – htxryan
    Aug 24, 2014 at 0:32
  • 1
    Thank you, you have saved my day, i was struggling from 1 day Sep 5, 2017 at 14:41
6

How to allow creating symlinks on windows this page helped me a lot which explains that this happens even if your shared folder is writable.

To fix it, you need to enable symlinks feature in VirtualBox.

Run at cmd prompt:

VBoxManage setextradata YOURVMNAME VBoxInternal2/SharedFoldersEnableSymlinksCreate/YOURSHAREFOLDERNAME 1

Then verify by:

VBoxManage getextradata YOURVMNAME enumerate

If your user belongs to Administrators group then start VirtualBox with "Run as Administrator"!

By default Windows 7 security policy does not allow creating symlinks as it's a potential security threat. Run "secpol.msc" and navigate to "Local Policies-User Rights Assignments" and add your user to "Create symbolic links". I didn't try that but could be that after that virtualbox could be run as a regular user.

0
3

Agree with lorem, but it's not enough.

  1. run Virtualbox 'as an admininstrator' on Windows.

  2. make sure you executed: VBoxManage.exe setextradata YOUR_VM BoxInternal2/SharedFoldersEnableSymlinksCreate/YOUR_SHARED_FOLDER 1

Replace the YOUR_VM and YOUR_SHARED_FOLDER with your values. You can check the value via: VBoxManage.exe getextradata boot2docker-vm enumerate

There is a virtualbox bug tracking this issue.

1

The newer versions of VirtualBox should allow symlinks if you start VirtualBox as Adminstrator (right click: Run as administrator).

Same applies to vagrant boxes: just run your cmd.exe/PowerShell as admin and you are good to go.

0

in this npm issue @drmyersii give a great solution, I'll only copy and paste to don't link the answer only.

The real solution here would be to set your configuration to allow symlinks on Windows hosts in your Vagrantfile. Here's an example (assuming that you are running it in VirtualBox):

config.vm.provider "virtualbox" do |v|
    v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/vagrant", "1"]
end

this worked great for me and now I can use gulp with scotchbox.

0

For me none of these answers worked. I'm not sure why but I believe it's because my share is nfs. So I couldn't get it to allow symlinks even when running as Administrator and changing the setextradata settings. I was working with gulp and some other packages that seem to have issues obeying --no-bin-links. It was STILL trying to create some symbolic links and obviously failing. Finally this thread on Github clued me into a "solution", hacky as it may be. I "simply" installed the project in my non-shared folder and set that as my NODEPATH.

export NODE_PATH=/home/vagrant/PROJECTNAME/node_modules

Caveat is that it will affect the entire server and the workflow of updating/changing the packaging.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .