Blog Posts

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.

Related Entries:
- How I use Docker on OS X

About the author

Comments [4]

John Wards, 25.07.2012 15:30 CET

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.

Lukas, 08.12.2012 01:51 CET

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

Andy, 16.05.2013 15:10 CET

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.

Jonas, 29.05.2014 14:44 CET

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: http://jonaszumkehr.ch/blog/vagrant-nodejs-zum-laufen-bringen/

Add a comment

Your email adress will never be published. Comment spam will be deleted!