Npm install on vagrant virtualbox

npmvagrantvirtualbox

Seem to be having A LOT of trouble figuring this one out, but I'm attempting to use vagrant and provision a server that uses node / npm to install dependencies. My setup is:

  • ubuntu 12.04 host (old dev environment)
  • ubuntu 12.04 guest (created via vagrant)
  • using shell provisioner to setup my server (php 5.3, apache, mysql)
  • all is good, everything installs, UNTIL I get to the npm install command

In my case, npm install seems to install everything (lots of terminal output, etc…). The next line in the provisioning script does grunt someTask to which I get "grunt command not found". So even though npm install appeared to install everything in reality it didn't.

In researching, it seems to be an issue with virtualbox and symlinks in a shared folder. I've added:

config.vm.provider "virtualbox" do |vb|
  # Use VBoxManage to customize the VM. For example to change memory:
  vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/vagrant", "1"]
  vb.customize ["modifyvm", :id, "--memory", "1024"]

end

which seems to have no effect. I also attempted install with the --no-bin-links flag, again, seems to have no effect. Any ideas how I can get npm to install my project dependencies properly? Thanks so much for any input.

EDIT:

This gist, https://gist.github.com/anonymous/b760fdfa9c204c24424b is the output I get when I run vagrant up. As you can see it appears as if everything is installing, yet, when I ssh into the box, or even from the provisioning script, I can not run "grunt" as it says it's not installed. There is a node_modules in my repo after the npm install --no-bin-links is complete.

Best Answer

You need to install grunt as it seems it is not being installed by your provisioning script.

To install it globally run this command:

npm install -g grunt-cli

You can either run it manually or add it to your provisioning script.