Symbolic Links With Vagrant Windows

There are few known limitations when using Vagrant on Windows machine. One of these limitations is the lack of symbolic links support on synced folder.

Symbolic links are used heavily by NPM to create shortcut for the libraries. I posted more details about this here:

Most of the time, you can get away with ‘npm –no-bin-link’ solution. However, you need more robust solution if you are using complex tools such as Grunt or Yeoman.

In this post, I’ll show you the proper way to add symbolic links support to your Vagrant machine.

First, you need to add this code snippet inside your Vagrantfile

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

VirtualBox disables symbolic links for security reasons. In order to pass this restriction, you need to boot up the Vagrant machine in Administrator mode.

You can do this by simply right clicking on your Command Prompt or Git Bash icon and click ‘Run as Administrator’. See the picture below if you can’t find it.

After that, boot up the Vagrant machine normally with ‘vagrant up’ command. Wait until the machine boots up, SSH to the machine and try to create symbolic link in the synced folder.

File path 255 character limit

Another annoying problem you might encounter is file path character limit. This happens quite often if you are using a node module with long name. You can easily solve this by following these steps:

Create ‘node_modules’ folder in your home folder

  mkdir ~/node_modules
  ln -sf ~/node_modules /vagrant/your-project-folder

This solution will ensure that all the node modules are stored inside home directory instead of synced folder.

comments powered by Disqus