NPM, Vagrant, Linux on Windows, shared directories and –no-bin-links

Error: UNKNOWN, unlink '/var/www/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/'

At its root, this is a permissions issue. Linux, running in virtual machine, has tried to make a directory in the Windows file system and been denied permission to do so. This line from the npm logs is talking about a failure to delete a file that doesn’t exist since it wasn’t created.

NPM to the rescue

Fortunately, NPM added a new option in 1.2.4, documented here:

The –no-bin-links argument will prevent npm from creating symlinks for any binaries the package might contain.

With this flag set, installing packages like grunt-contrib-phantomjs is now possible without other bizarre workarounds.

npm install grunt-contrib-phantomjs --no-bin-links