Nodejs + npm, installing modules on ntfs partition
Asked Answered
K

7

35

I have a problem when installing npm modules. NodeJS is installed on Ubuntu 11.10 running on Virtual Box on Windows host. My project files are on NTFS partition (I have to share them with windows). When I try to install some npm module I get an error, and module is not installed. I've found out that problem occurs when npm tries to create symbolic links.

Probably you can not create symlinks on NTFS partition, when I'm installing module "inside" Linux file system, everything works fine.

How can I fix this? I don't want to resolve dependencies manually :/

Kowalczyk answered 22/11, 2011 at 19:45 Comment(2)
I think NTFS does have a symlink equivalent, but it's only usable for admins and not as heavily used as on linux, so maybe the ntfs driver doesn't support it.Sebastien
any ideas how to fix it?Kowalczyk
C
56

Since version 1.2.21, npm has a new option for the install command. --no-bin-links

You can use if for installing a specific node module

npm install express --no-bin-links

and also for a package.json install

npm install --no-bin-links

With this option I've been able to install many npm modules without problems in my shared forlder inside the VM (Ubuntu guest, Windows Host)

The commit where the option was added to the npm code is b4c58617039c21c10889a9869f8e86a23e17d3a0

Chiropodist answered 1/3, 2013 at 15:45 Comment(4)
This is awesome! Sosnowski that is quick solution which will not need setting a vbox setting on each workstation as suggested by @MahbubChimney
This should be marked as the correct answer. After spending hours trying to fix this and me tinkering with my cifs mount, thinking that it was some permission issue, this fixed it for me.Supposititious
This is briliant solution!Northwestwards
This also affects the Windows Subsystem for Linux so I'm glad that this has already been caught for NTFS filesystems.Flux
L
5

Try this - http://ahtik.com/blog/2012/08/16/fixing-your-virtualbox-shared-folder-symlink-error/

Works for me!

Basically you set a parameter

VBoxManage setextradata YOURVMNAME VBoxInternal2/SharedFoldersEnableSymlinksCreate/YOURSHAREFOLDERNAME 1

And then run the VM as an administrator....

Lunalunacy answered 4/3, 2013 at 16:39 Comment(5)
That is still showing me Error: UNKNOWN, symlink '../coffee-script/bin/cake' after I run npm installChimney
Oups - I needed to run the whole VBox as admin. I works fine now but it still is a bit bothersome to run this as admin every time.Chimney
I know it's a pain :), you can set your VM to run as administrator all the time. Right click on virtual box > properties > Shotcut > Advanced ... > Run as administrator.Lunalunacy
Have your tried vagrant? Check this out - github.com/mitchellh/vagrant/issues/713#issuecomment-4416384Lunalunacy
broken link "page not found..."Seventieth
D
5

The Symlink permissions, or the --no-bin-links didn't work for us. Instead we opted to move our node_modules away from the /vagrant share. We created a symlink from /vagrant/node_modules to /tmp/node_modules. You can only do this if your node_modules is not in version control. Check this first!

Also see http://kmile.nl/post/73956428426/npm-vagrant-and-symlinks-on-windows

Dolorisdolorita answered 20/1, 2014 at 16:38 Comment(0)
C
3

I am pretty certain symlinks can't be created on the shared drive ("shared folder"). Even more impossible with a Windows host machine and a Linux guest.

The host machines are not aware of the filesystem of the guests. A guest machine is a blackbox for the host. You can't say to the host "Well this links to /etc/..." when the host doesn't know where this /etc is :).

So in short: unfortunately no.


In some more detail:

I would be really happy if I am wrong! It is a major pain in my development process.

I tried so many options. By default the filesystem that the "shared folders" use is vboxsf, something if not the same as samba (default network sharing protocol for windows) so:

  1. I tried using native Windows network sharing and then mounting the network drive in the guest as the guest and host are on the same network. The problem was still there.
  2. I tried running a NFS server on windows (Hanewin NFS Server) along with SFU/SUA (Windows Services for UNIX) but this has problems with GIT locks. Probably other problems as well - it was a while ago and I don't clearly remember
  3. I tried the reverse: sharing a directory on the virtual machine to windows. But that is stupid as all the files will be on the virtual box and is reaally slow to access on windows
  4. I was being stupid and I though "well let's mount a virtual drive on both windows and linux" - don't try this, corrupts the virtual disk. Something I should have known.

There might be a network sharing protocol other than samba and nfs which will perhaps copy the files whenever "symlink" creation is attempted? I don't know really.

However I haven't found one yet and also "locking" seems to to be a task of the file-system itself so I doubt any network protocol (unless having a dedicated registry of some sort for locks) can do this.

Chimney answered 30/9, 2012 at 11:55 Comment(0)
W
1

For anyone still having this problem after trying npm install --no-bin-links.

I wasn't able to get any of the above solutions to work when I came across a similar issue running npm install on a Laravel Homestead Vagrant box on a Windows 7 host using VirtualBox. The guest box has a mapped directory to the Windows file system.

The problem was causing various error messages and failed package installations. The one that is most relevant to the question was npm ERR! UNKNOWN, symlink '<some filename>'.

To fix this, I was able to successfully run npm install on the Git bash command line on Windows rather than bash on the guest Linux.

To do this, you will need to install Git for Windows and NodeJS (both on your Windows box).

e.g.

  1. Install Chocolatey https://chocolatey.org/
  2. choco install nodejs.install
  3. choco install git.install
  4. Run C:\Program Files (x86)\Git\Git Bash.vbs
  5. In the Git Bash command line, change directory to the location of your package.json file e.g. cd /c/projects/projectname
  6. Run npm install

Everything appears to install successfully.

Weatherford answered 7/7, 2015 at 8:18 Comment(0)
P
0

If you don't use native modules (compiled from C/C++) you can just use npm on your Ubuntu VM and copy the node_modules folder to you windows drive.

Policewoman answered 16/4, 2012 at 20:52 Comment(0)
D
0

fsutil behavior set SymlinkEvaluation L2L:1 R2R:1 L2R:1 R2L:1

this command enables symlinks on windows. for a better explanation to the cryptic commands at the end visit: How do I overcome the "The symbolic link cannot be followed because its type is disabled." error when getting the target of a symbolic link on Server 2008?

in summary

The behavior codes for fsutil behavior set SymlinkEvaluation - namely L2L, L2R, R2L, and R2R - mean the following:

L stands for "Local", and R for "Remote" (who would've thunk?) The FIRST L or R - before the 2 - refers to the location of the link itself (as opposed to its target) relative to the machine ACCESSING the link. The SECOND L or R - after the 2 - refers to the location of the link's target relative to the machine where the LINK itself is located.

Desimone answered 3/2, 2016 at 13:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.