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.

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:

Issue 1: npm install hangs

vagrant@oneric32:/www/bgc/bgc-api$ npm install
npm http GET https://registry.npmjs.org/express/2.5.8
npm http GET https://registry.npmjs.org/underscore/1.3.3
npm http GET https://registry.npmjs.org/jade
npm http GET https://registry.npmjs.org/hiredis/0.1.14
npm http GET https://registry.npmjs.org/socket.io/0.8.6
npm http GET https://registry.npmjs.org/redis/0.7.2
npm http GET https://registry.npmjs.org/socket.io-client/0.8.6
HANGING

This is somewhat resolved by creating the directory from the host
machine (or before installing)

Issue 2: npm cannot access/find files:

npm http GET https://registry.npmjs.org/express/2.5.8
npm http GET https://registry.npmjs.org/underscore/1.3.3
npm http GET https://registry.npmjs.org/jade
npm http GET https://registry.npmjs.org/hiredis/0.1.14
npm http GET https://registry.npmjs.org/socket.io/0.8.6
npm http GET https://registry.npmjs.org/redis/0.7.2
npm http GET https://registry.npmjs.org/socket.io-client/0.8.6
npm http GET https://registry.npmjs.org/coffee-script/1.3.1
npm ERR! Could not create
/www/bgc/bgc-api/node_modules/_<strong>underscore.npm
npm ERR! error installing underscore@1.3.3
npm ERR! Could not create
/www/bgc/bgc-api/node_modules/</strong>_express.npm
npm ERR! error installing express@2.5.8
npm ERR! Could not create
/www/bgc/bgc-api/node_modules/_<strong>socket.io.npm
npm ERR! error installing socket.io@0.8.6
npm ERR! Could not create
/www/bgc/bgc-api/node_modules/</strong>_coffee-script.npm
npm ERR! error installing coffee-script@1.3.1
npm ERR! Could not create
/www/bgc/bgc-api/node_modules/_<strong>socket.io-client.npm
npm ERR! error installing socket.io-client@0.8.6
npm ERR! Could not create
/www/bgc/bgc-api/node_modules/</strong>_hiredis.npm
npm ERR! error installing hiredis@0.1.14
npm ERR! Could not create
/www/bgc/bgc-api/node_modules/_<strong>jade.npm
npm ERR! error installing jade@0.25.0
npm ERR! Could not create
/www/bgc/bgc-api/node_modules/</strong>_redis.npm
npm ERR! error installing redis@0.7.2

npm ERR! Error: UNKNOWN, unknown error
'/www/bgc/bgc-api/node_modules'
npm ERR! You may report this log at:
npm ERR!     &lt;//github.com/isaacs/npm/issues&gt;
npm ERR! or email it to:
npm ERR!     &lt;npm-@googlegroups.com&gt;
npm ERR!
npm ERR! System Linux 3.0.0-12-generic
npm ERR! command &quot;node&quot; &quot;/usr/local/bin/npm&quot; &quot;install&quot;
npm ERR! cwd /www/bgc/bgc-api
npm ERR! node -v v0.6.11
npm ERR! npm -v 1.1.2
npm ERR! path /www/bgc/bgc-api/node_modules
npm ERR! code UNKNOWN
npm ERR! message UNKNOWN, unknown error
'/www/bgc/bgc-api/node_modules'
npm ERR! errno {}
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /www/bgc/bgc-api/npm-debug.log
npm not ok

  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.