0

I am trying to install bower on CentOS 7, after installing node.js. To install node.js I followed these steps:

Step1: wget http://nodejs.org/dist/v0.10.30/node-v0.10.30.tar.gz

Step2: tar xzvf node-v* && cd node-v*

Step3: sudo yum install gcc gcc-c++

Step4: ./configure

Step5: make

Step6: sudo make install

Step7: node --version

I had successfully installed nodejs, I followed this steps from Install Nodejs

Then installed npm by running command sudo yum install npm.

Now I am trying to install bower. I ran the following command npm install -g bower. But getting the following error. Please tell me how to install bower correctly.

[neelabh@localhost node-v0.12.7]$ npm install -g bower
npm ERR! tar.unpack untar error /home/neelabh/.npm/bower/1.4.1/package.tgz
npm ERR! Linux 3.10.0-123.el7.x86_64
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "bower"
npm ERR! node v0.12.7
npm ERR! npm  v2.11.3
npm ERR! path /usr/local/lib/node_modules/bower
npm ERR! code EACCES
npm ERR! errno -13

npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/bower'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES, mkdir '/usr/local/lib/node_modules/bower']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/usr/local/lib/node_modules/bower',
npm ERR!   fstream_type: 'Directory',
npm ERR!   fstream_path: '/usr/local/lib/node_modules/bower',
npm ERR!   fstream_class: 'DirWriter',
npm ERR!   fstream_stack: 
npm ERR!    [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:35:25',
npm ERR!      '/usr/local/lib/node_modules/npm/node_modules /mkdirp/index.js:47:53',
npm ERR!      'FSReqWrap.oncomplete (fs.js:95: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!     /home/neelabh/Downloads/Softwares/node-v0.12.7/npm-debug.log
1

The problem is that you cannot write to the /usr/local/lib/node_modules/ using your user neelabh:

npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/bower'

As you can see, you have no permission to create a new directory.

There are two solutions:

  1. Run npm install -g as root.
  2. Change the permissions so that your user can write to /usr/local/lib/node_modules. The best way to do that is probably to create a new group (e.g., src), give it permission to write to that directory and then add your user to that group.

I'd probably go with option 2 as I'd be wary of running a node module installer as root.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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