Vagrant and Node.js quick tip

  • Alvaro Videla

For one of our projects we are using Vagrant and Chef to provision virtual machines for development. The idea as you might know already is to have the same development environment for all devs.

Vagrant shares with the Virtual Machine the folder where the Vagrantfile resides, so when we had to check out a project into the virtual machine we just cloned it into the Vagrantfile folder.

All good up to that point but then we tried to run npm install over ssh to get the node.js modules into the Virtual machine project and it failed. The problem was that you can't create symlinks into shared folder. One of ops guys found a solution for that problem. Basically you need to have the following code in your Vagrant file:

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

That will allow npm to create symlinks for the modules that require it.

So I hope this little tip courtesy of our Good Guy Reto will save you some time.

Tell us what you think