New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poor documentation that Vagrant does not support NPM on shared folder if both host and client run Windows #5844

Closed
nfloersch opened this Issue Jun 18, 2015 · 6 comments

Comments

Projects
None yet
4 participants
@nfloersch
Copy link

nfloersch commented Jun 18, 2015

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:

config.vm.provider "vmware_workstation" do |v|
  #v.gui = true
  v.vmx["sharedFolder0.followSymlinks"] = "TRUE"
end

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.

npm install pg --no-bin-links

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.

@mitchellh

This comment has been minimized.

Copy link
Member

mitchellh commented Jun 18, 2015

Sounds good to me, we'll add it to the docs

mitchellh added a commit that referenced this issue Jul 7, 2015

@mitchellh

This comment has been minimized.

Copy link
Member

mitchellh commented Jul 7, 2015

Done

@nfloersch

This comment has been minimized.

Copy link
Author

nfloersch commented Jan 13, 2016

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?

On Jan 13, 2016, at 1:50 PM, Christoph Pernsteiner notifications@github.com wrote:

@nfloersch https://github.com/nfloersch: Symlinks are finally working perfect on the following setup. I spent nearly 2 weeks figuring out how to best setup a fast Symonfy2 dev environment with gulp thus having npm node.js as requirement on a windows 10 host.

The key was as stated above to move out the node_modules folder to a place somewhere on the native guest OS filesystem and symlinking to that folder. Symlinks work perfectly on Windows Host, Linux guest via using the mfsymlinks emulation.

Attention: you need a guest os with linux kernel > 3.18 for the following to work (e.g. ubuntu/vivid64)

config.vm.synced_folder "/projectfolder/www", "/var/www", type: "smb", mount_options: ["vers=3.02","mfsymlinks"]

Key was using smb3 aswell as mfsymlinks as stated above. Before I ran into a lot of problems on my windows host using symonfy2 and gulp/npm/node.js, mainly because of bad vboxfs performance and being unable to use symlinks. My standard page loads where ~ 17.000 ms per page in development mode, now I run them with 500 ms.


Reply to this email directly or view it on GitHub #5844 (comment).

@Perni1984

This comment has been minimized.

Copy link

Perni1984 commented Jan 14, 2016

@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.

@Perni1984

This comment has been minimized.

Copy link

Perni1984 commented Jan 14, 2016

@nfloersch:
Thinking a bit longer twice about it, the following setup might work, but it's pure speculation!

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:
https://msdn.microsoft.com/en-us/virtualization/hyperv_on_windows/user_guide/nesting

Now I am not sure if you can put a Linux guest in between, or all guests have to be on windows.

@sarbull

This comment has been minimized.

Copy link

sarbull commented Apr 11, 2018

No one tested this? :)

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