in Troubleshooting

NPM, Vagrant Weirdness

I have been using Vagrant to configure a nodejs/redis development server. When I setup my application and ran a npm install on the guest machine based on a local package.json file, I’d get weird installation errors such as npm not being able to find node module package.json files. Another error I’d get intermittently is just a hanging install. A sample is included below.

Then, I figured I’d try the same command from the host machine. It worked flawlessly. Then, I remembered that there might be performance problems with Virtual Box’s shared folders. Indeed, this article describes the problem and suggests using nfs.

My share_folder command looks something like this in my Vagrantfile.

1
2
3
Vagrant::Config.run do |config|
  config.vm.share_folder "v-www", "/www", "/Users/jamiely/Documents/code/", :nfs => true
end

Initially, I had problems with this because the path I was sharing was a symbolic link. I didn’t realize this would be a problem and it took some manual experimentation with the NFS setup to determine what the issue was.

Here’s the sample npm output in case it’s helpful to anyone:

  1. Thanks for taking the time to write this. I just had the same issue trying to setup node/npm on a vagrant box at work.

Comments are closed.