Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Poor documentation that Vagrant does not support NPM on shared folder if both host and client run Windows #5844
Given that using Vagrant as a development environment is a big part of its draw, and NPM is crazy popular amongst web developers in all parts of the stack, that NPM basically won't work on a synced folder when the Vagrant host and client are both running Windows seems like an important caveat.
There are some workarounds, but they appear to be only workarounds, not solutions.
This lack of clarity is not strictly a Vagrant bug, but I think it should be made a lot clearer in the Vagrant documentation so new users don't waste tons of time trying to solve this problem. I suggest a warning on the main "Synced Folders" page in the documentation.
As stated in issue #5834 Vagrant does not seem to do Rsync support well when the host and client are running Windows. If this gets fixed, or a proper setup is more clearly documented, then in theory the whole Vagrant-NPM-Windows problem could be resolved.
Otherwise, because Windows does not support symbolic links on shared folders, NPM just does not work properly when the "node_modules" folder is stored on such a shared folder (such as the Vagrant "synchronized folder"). Likewise because you cannot use symbolic links on a shared folder, you cannot trick the system by moving the node_modules to a non-shared-folder location and putting a symbolic link in that points to it.
If the host is Linux/Mac and the client is Windows, then enabling symbolic link support on the shared folders in the VM provider seems to be enough to allow Windows to use NPM on the Vagrant synchronized folder.
For VMWare Fusion we can do this by putting this in the Vagrantfile:
There is a similar setting that can be enabled in VirtualBox. I'm not sure about VMWare Workstation on Linux.
Some packages may be installable to the shared folder by NPM if you use the "--no-bin-links" parameter.
But any Node package that needs to install a runnable command will not get the runnable command installed properly if --no-bin-links is used.
added a commit
Jul 7, 2015
referenced this issue
Aug 26, 2015
While I really appreciate the follow-up, I am not clear this solves our problems. We have Windows Vagrants on Windows Hosts. Or we, would, but we couldn’t get it working. So we don’t. Has this been tested in a Windows-on-Windows setup?
@nfloersch: sorry, I misread the post above, and thought it's about generally getting NPM to run inside a VM on a windows host, which in fact I only got working when I am using the mfsymlinks emulation. After carefully reading your post again, I found out that my solution will not really help you, that's why I deleted my message. Sorry for the inconvenience. Unfortunately my solution for windows/Linux guest won't help you solve the windows-on-Windows problem. I am not even sure this is solveable at this point.
Windows Host <---> Linux Guest (mfsymlinks emulation) <----> Windows Guest
Although I read that it's not possible via VirtualBox as nested VM's are not supported, there is a summary thread for VMWare about the possibilities of nested VMs: https://communities.vmware.com/docs/DOC-8970
Apparently Windows 10 is also supporting nested virtualization with Hyper-V:
Now I am not sure if you can put a Linux guest in between, or all guests have to be on windows.