NPM install failure - paths too long?


I have a Vagrant VM with bedrock ansible up and running on a Windows machine. I am now at the point of doing ‘npm install’ in the theme folder. I have the latest version of all the required software.

I have followed the information in the NPM debugging guidelines, and I have also tried following the instructions at this link
I cannot get past the issue. I can run npm globally without sudo.

When I put my ‘’ folder to the C’ drive root I am able to get less errors and more npm processes complete but a lot also fail.

npm ERR! Linux 3.13.0-35-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! node v0.12.3
npm ERR! npm  v2.9.1
npm ERR! path /srv/www/
npm ERR! code EPERM
npm ERR! errno -1

npm ERR! Error: EPERM, open '/srv/www/'
npm ERR!     at Error (native)
npm ERR!  { [Error: EPERM, open '/srv/www/']
npm ERR!   errno: -1,
npm ERR!   code: 'EPERM',
npm ERR!   path: '/srv/www/' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm WARN optional dep failed, continuing imagemin-optipng@4.2.0
npm ERR! Linux 3.13.0-35-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! node v0.12.3
npm ERR! npm  v2.9.1
npm ERR! path /srv/www/
npm ERR! code EPERM
npm ERR! errno -1

In order to get Sage working properly on Windows 8.1, you’ll need to complete these steps
before your first ‘vagrant up’. This should work without any issues, and help you get through the above problem.

As of 8/5/15, this works with lastest release of Trellis, Bedrock, & Sage.


Windows 8.1 PC Host
Vagrant 1.7.4
Virtualbox 4.3.30
Vagrant-hostsupdater plugin
Putty SSH Client (Windows doesn’t come with one)
PuttyGen (Generates SSH Keys)

***Symlinks did not work when using VirtualBox 5.0.0
I believe it has something to do with the vagrant guest additions, but I’m no expert.
While running vagrantup, you’ll see the guest additions are only up to Vbox 4.3.10

By default, VirtualBox disables symlinks for security reasons. So we need to enable this
in our Vagrantfile so we can use symlinks in the next steps.

config.vm.provider "virtualbox" do |vb|
    vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/vagrant", "1"]
    vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/current", "1"]

Now we need to enable symlinks between (L)ocal and ®emote machines on our Windows host.
Run the following command in an admin command prompt and then restart your machine
for it to take effect. This command enables all forms of symlinks between local and
remote machines.

fsutil behavior set SymlinkEvaluation L2L:1 R2R:1 L2R:1 R2L:1

You can now run ‘vagrant up’. Make sure you do this in an admin command prompt.

The above instructions are a modified version of the information contained at

The newest release of the roots setup requires an SSH Key in order to access the Virtual Machine.
People who don’t use Windows can type ‘vagrant ssh’ and that activates an ssh session in the cmd prompt and the program already knows the location of the SSH key.

However, if you use Windows, when you run ‘vagrant ssh’ Vagrant will instead output SSH authentication info which you can use with your favorite SSH client, such as PuTTY. An SSH client is generally not distributed with Windows by default.

PuTTY may not recognize the insecure_private_key provided by vagrant as a valid private key. To remedy this, first grab the PuTTYgen app. Then use PuTTYgen and import the insecure_private_key (found in the .vagrant.d dir in your home directory) and save a ppk file from that private key. Use the ppk file instead of the default one when SSHing into your vagrant box.

Open the PuttyGen program, select ‘Conversions’ from the top menu, and then select 'Import Key’
You should find your key in


Select ‘Save private key’ and save it without a passphrase.

I saved the file as private_key_putty.ppk

In PUTTY navigate to Connection > SSH > Auth in the lefthand category menu.

Click browse on the ‘Private key file for authentication’ & select your private key file from earlier.

After you enter all the proper details, you should save these settings as a Session in putty, so you do not have to do this everytime.

In your VM via SSH

mkdir /srv/www/sitename/node_modules
sudo chown vagrant:www-data /srv/www/sitename/node_modules

Copy the package.json from your theme folder and put it in /srv/www/sitename

cp /srv/www/sitename/current/web/app/themes/themename/package.json /srv/www/sitename
sudo chown vagrant:www-data /srv/www/sitename/package.json

Get the latest version of nodejs & npm

curl -sL | sudo bash -
sudo apt-get install nodejs 

Clear npm cache and remove any node_modules folder that may have been in your theme folder

cd /srv/www/sitename/current/web/app/themes/themename
npm cache clear && rm -rf node_modules

Now we need to bypass Window’s 260 character file length limit. Because of npm’s deeply nested folder structure, getting over 260 character paths is pretty likely. To get around this, we will use a symlink so npm directories are not written back to the Window’s host machine.

ln -s /srv/www/sitename/node_modules /srv/www/sitename/current/web/app/themes/themename/

Follow the instructions at this link to get npm working without using sudo

Install gulp and Bower globally with

npm install -g gulp
npm install -g bower

Navigate to the new node_modules directory and run the npm install

cd /srv/www/sitename/
npm install

Navigate to the theme directory and install bower

cd /srv/www/sitename/current/web/app/themes/themename/
bower install

Hope I made this clear enough.
You will need to do this on every first ‘vagrant up’ and after a ‘vagrant destroy’ per virtual machine