Vagrant and Node.js quick tip

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.

I generally use network shares, especially in a Mac environment using Symfony2 sites, which means you don’t have to worry about this. “It just works”

Downside is that you can’t use the very hand bridged networking.

Thanks a lot. This saved me tons of time. Cheers!

Cheers for this, I’m using a Win 7 host so ultimately had to use npm install –no-bin-links to get it working. Put me on the right track though.

I had other kinds of troubles: Needed to figure out how to properly install NodeJS and to run the command line as administrator (using windows). No need to configure anything else. I’ve written a short post about it, maybe it’s helpful for others: