Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What permissions do I need to install Bower on Vagrant on Windows?

I kept running into this error when installing Bower through NPM on a Windows 7 machine running a precise32 Ubuntu Box on Vagrant. I tried every combination of commands and always got the same or very similar errors

Installing locally, globally, with sudo, without sudo, etc.

...
npm ERR! Error: EPERM, open '/home/vagrant/tmp/npm-1214-AHbOCwuM/1391873680685-0.36021817452274263/package/build/node_modules/cheerio/node_modules/htmlparser2/node_modules/readable-stream/test/simple/test-stream2-readable-empty-buffer-no-eof.js'
npm ERR!  { [Error: EPERM, open '/home/vagrant/tmp/npm-1214-AHbOCwuM/1391873680685-0.36021817452274263/package/build/node_modules/cheerio/node_modules/htmlparser2/node_modules/readable-stream/test/simple/test-stream2-readable-empty-buffer-no-eof.js']
npm ERR!   errno: 50,
npm ERR!   code: 'EPERM',
npm ERR!   path: '/home/vagrant/tmp/npm-1214-AHbOCwuM/1391873680685-0.36021817452274263/package/build/node_modules/cheerio/node_modules/htmlparser2/node_modules/readable-stream/test/simple/test-stream2-readable-empty-buffer-no-eof.js' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Linux 3.2.0-23-generic-pae
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "-g" "bower" "--no-bin-links"
npm ERR! cwd /home/vagrant
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.24
npm ERR! path /home/vagrant/tmp/npm-1214-AHbOCwuM/1391873680685-0.36021817452274263/package/build/node_modules/cheerio/node_modules/htmlparser2/node_modules/readable-stream/test/simple/test-stream2-readable-empty-buffer-no-eof.js
npm ERR! code EPERM
npm ERR! errno 50
npm ERR! stack Error: EPERM, open '/home/vagrant/tmp/npm-1214-AHbOCwuM/1391873680685-0.36021817452274263/package/build/node_modules/cheerio/node_modules/htmlparser2/node_modules/readable-stream/test/simple/test-stream2-readable-empty-buffer-no-eof.js'
...

EDIT: As well as my answer below please note the file directory + file size limitation when using Windows (260 characters I believe)

I have had to install vagrant in a folder directly on my c:/ drive to get over this limitation as some packages end up having nested dependencies causing this limit to be exceeded. My problem was with grunt-contrib-less

like image 224
Sam Avatar asked Feb 08 '14 15:02

Sam


1 Answers

Self answering as I couldn't find a solution anywhere else on StackOverflow

I eventually got it to work via changing to the root user via su root and trying to install globally again. Apparently just using sudo wasn't enough.

So it became

root@precise32: npm install -g bower --no-bin-links

EDIT: As well as this solution please note the file directory + file size limitation when using Windows (260 characters I believe)

I have had to init a vagrant instance in a folder directly on my c:/ drive to get over this limitation as some packages end up having nested dependencies causing this limit to be exceeded. My problem was with grunt-contrib-less

EDIT 2: After coming across this problem again and again I'll add a bit more information for people here regarding node modules and vagrant under Windows.

I now overcome the file path limitation via putting any long dependency chains that fail due to path length (usually EPERM) I add one of the packages in the chain to my own package.json. This means the long requirement chain is split as npm does not re-install the package deeper in the tree if it's already installed.

Just make sure you require a version which is valid for the version string for the module.

The order of the dependencies in package.json does not matter, dependencies are resolved before anything is installed

like image 54
Sam Avatar answered Nov 15 '22 23:11

Sam