5

I have a fairly vanilla Vagrant box configured using Puphpet with Node installed.

However, when I ssh into the box and try npm install I seem to be having a raft of permissions issues.

Even running with sudo doesn't seem to work

Running into

npm ERR! tar.unpack untar error /home/vagrant/.npm/gulp-autoprefixer/2.1.0/package.tgz
npm ERR! tar.unpack untar error /home/vagrant/.npm/gulp-concat/2.5.2/package.tgz
npm ERR! tar.unpack untar error /home/vagrant/.npm/gulp-livereload/3.8.0/package.tgz
npm ERR! tar.unpack untar error /home/vagrant/.npm/path/0.11.14/package.tgz
npm ERR! tar.unpack untar error /home/vagrant/.npm/gulp-notify/2.2.0/package.tgz
npm ERR! tar.unpack untar error /home/vagrant/.npm/gulp-compass/2.0.3/package.tgz
npm ERR! tar.unpack untar error /home/vagrant/.npm/gulp-minify-css/0.4.6/package.tgz
npm ERR! tar.unpack untar error /home/vagrant/.npm/gulp-plumber/0.6.6/package.tgz
npm ERR! tar.unpack untar error /home/vagrant/.npm/gulp-rename/1.2.0/package.tgz
npm ERR! tar.unpack untar error /home/vagrant/.npm/gulp/3.8.11/package.tgz
npm ERR! tar.unpack untar error /home/vagrant/.npm/gulp-uglify/1.1.0/package.tgz
npm ERR! Linux 3.13.0-32-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v0.12.0
npm ERR! npm  v2.5.1
npm ERR! path /var/www/node_modules/gulp-autoprefixer/package.json
npm ERR! code EPERM
npm ERR! errno -1

npm ERR! Error: EPERM, chown '/var/www/node_modules/gulp-autoprefixer/package.json'
npm ERR!     at Error (native)
npm ERR!  { [Error: EPERM, chown '/var/www/node_modules/gulp-autoprefixer/package.json']
npm ERR!   errno: -1,
npm ERR!   code: 'EPERM',
npm ERR!   path: '/var/www/node_modules/gulp-autoprefixer/package.json',
npm ERR!   fstream_finish_call: 'chown',
npm ERR!   fstream_type: 'File',
npm ERR!   fstream_path: '/var/www/node_modules/gulp-autoprefixer/package.json',
npm ERR!   fstream_class: 'FileWriter',
npm ERR!   fstream_stack:
npm ERR!    [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/writer.js:308:19',
npm ERR!      '/usr/local/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:143:7',
npm ERR!      'FSReqWrap.oncomplete (evalmachine.<anonymous>:99:15)' ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     /var/www/npm-debug.log

I've read about writing into a shared folder and tried adding fixes to the Vagrantfile but with no success

      virtualbox.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]

Any ideas?

2 Answers 2

1

So turns out this was a bug with the Puphpet config like so https://github.com/puphpet/puphpet/issues/1378

The fix can be found in https://github.com/puphpet/puphpet/pull/1403 - just had to replace that snippet in my Vagrantfile and we're sweet. I can now npm install, bundle install etc.

0

Are you using Windows? Not only do you need to customize the VM, but you also need to start the VM while you have elevated rights (ie Run as Administrator). Overall, it is a complex mess.

If I'm working with something that needs symlinks in my shared folder (like npm), I've started using rsync folders. With rsync the /vagrant folder is no longer a Virtual Box shared folder, and doesn't have problems representing symlinks. As an extra benefit, it is also way faster.

5
  • 1
    I'm not, I'm running NFS on Mac as recommended because it's more performant I believe. Feb 27, 2015 at 10:56
  • Of all the options, rsync will be the fastest. Unfortunately, I can't help with a Mac! Feb 27, 2015 at 15:00
  • I'll give that a whirl, we need this box running for a Windows user in any case although we have another issue with them right now Feb 27, 2015 at 15:06
  • Thanks Chris. I'll check that out because we need this for Windows devs too. Feb 27, 2015 at 15:41
  • So if I use the default shared folder option from Puphpet - npm install and my gulp tasks write just fine. If I go with NFS or rsync, writing fails. Mar 3, 2015 at 21:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.