Vagrant, npm and windows 7

Over the past few months I’ve switch around my development methods. First it was SASS, then I moved my development environment to Ubuntu, by way of a physical box at home and Vagrant at work. I went the vagrant route essemtially as Apache on Windows was becoming annoying without a decent shell.

Then, yesterday I decided to give Grunt a try. If you’re not familiar with Grunt, it is a task runner powered by JavaScript and reliant on Node. Grunt can be used for a huge number of day to day tasks developers do, and some simple examples include concatenation and minification of JavaScript files, watching SASS, and so on.

I have to admit to being a little old fashioned when it comes to the tools that ‘help’ development for a varitey of reasons. On of the main ones being that it can lead to lesser coding standards in the form of lengthy selectors, especially in SASS, for eaxmple, I saw this beauty a few weeks ago:

nav.slide ul li ul, nav.slide ul li.current ul li ul, nav.slide ul li.current ul li.current ul li ul nav.slide ul li.current ul li.current ul li.current ul li ul, nav.slide ul li.current ul li.current ul li.current ul li.current ul li ul, nav.slide ul li.current ul li.current ul li.current ul li.current ul li.current ul li ul { display: none; } 

Nice, huh? But I digress.

When running through this great article on Grunt by Chris Coyier, I found, contrary to the article title, it is hard and weird. Ok, maybe it’s not Grunt, but the environment I was working in. As I mentioned, I’m running Vagrant at work on Windows 7. Every time I tried to install grunt to a project I was greeted by a pretty sizable list of errors. Some were easily fixed, like having a more up to date version on Node. Others, not so much. I googled and… nothing.

I hunted around for the best part of 3 hours looking for the first error and then stumbled upon a possible solution. Essentially, when installing via NPM, certain SymLinks are created. Windows, however, was not allowing this. Some more trips to Google returned the following line of Vagrant config:

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

Sadly, Vagrant didn’t like it.

Then, I found a post this morning and all was well. A patch was added to npm install to stop it forcing SymLinks. So when running the command in a virtual machine, use the following:

npm install --no-bin-link

After this, I was up and running within about 20 minutes, and, totally sold into having Grunt automate many tedious tasks for me. Win!

For reference, the post I discovered the solution on was by Max Claus Nunes, which led me to this post by Paul Conroy. My hat is truly doffed.