Installing Bower on Ubuntu 14.04 LTS

Bower is a package manager for the web and offers a generic solution to the problem of front-end package management. For example the Polymer library uses Bower for package management. In fact, the primary reason for me to install Bower was to use Polymer. The main difference between Bower and pther package managers is that Bower will manage any packages, even if that means HTML, CSS, or images. In this case, a package means any third-party code, usually publicly accessible from a Git repository.

Bower depends on Node and npm so first you will need to install NodeJS. For Ubuntu 13.10 and 14.04 and above, 0.10.X versions of Node are present.

sudo apt-get install nodejs

Then install npm.

sudo apt-get install npm

Bower also requires git to be installed as some bower packages require it to be fetched and installed. On my Ubuntu 14.04 LTS, git was installed by default, so no messing around there.

Next install Bower.

sudo npm install -g bower

Now run Bower. Note that some Linux distributions install nodejs not as “node” executable but as “nodejs”. This can throw the following error when running Bower.

/usr/bin/env: node: No such file or directory

This caused some wasted time, however some searching around found a fix. In this case you can do an easy symlink. For Linux distributions which install package binaries to /usr/bin you can do the following.

ln -s /usr/bin/nodejs /usr/bin/node

Some users suggest installing legacy nodejs, this package just creates a symbolic link to binary nodejs.

sudo apt-get install nodejs-legacy

Now that everything is installed, check to see if Bower is correctly working. Lets check Bower version.

bower -version
1.3.3


20 thoughts on “Installing Bower on Ubuntu 14.04 LTS

  1. Changing user of whole /usr/local folder is not the solution to npm install -g failing…
    global packages must be installed using sudo in ubuntu. simply “sudo npm install -g bower” shoud have worked.

  2. Can’t get bower installed in my Ubuntu 32-bit 12.04 LTS system. “npm install -g bower
    ” doesn’t seem to be working even after executing that “sudo chown -R $USER /usr/local
    ” command.
    Running “npm install -g bower” shows

    npm http GET https://registry.npmjs.org/bower

    npm ERR! Error: failed to fetch from registry: bower
    npm ERR! at /usr/share/npm/lib/utils/npm-registry-client/get.js:139:12
    npm ERR! at cb (/usr/share/npm/lib/utils/npm-registry-client/request.js:31:9)
    npm ERR! at Request._callback (/usr/share/npm/lib/utils/npm-registry-client/request.js:136:18)
    npm ERR! at Request.callback (/usr/lib/nodejs/request/main.js:119:22)
    npm ERR! at Request. (/usr/lib/nodejs/request/main.js:212:58)
    npm ERR! at Request.emit (events.js:88:20)
    npm ERR! at ClientRequest. (/usr/lib/nodejs/request/main.js:412:12)
    npm ERR! at ClientRequest.emit (events.js:67:17)
    npm ERR! at HTTPParser.onIncoming (http.js:1261:11)
    npm ERR! at HTTPParser.onHeadersComplete (http.js:102:31)
    npm ERR! You may report this log at:
    npm ERR!
    npm ERR! or use
    npm ERR! reportbug –attach /home/prakhar/npm-debug.log npm
    npm ERR!
    npm ERR! System Linux 3.2.0-74-generic-pae
    npm ERR! command “node” “/usr/bin/npm” “install” “-g” “bower”
    npm ERR! cwd /home/prakhar
    npm ERR! node -v v0.6.12
    npm ERR! npm -v 1.1.4
    npm ERR! message failed to fetch from registry: bower
    npm ERR!
    npm ERR! Additional logging details can be found in:
    npm ERR! /home/prakhar/npm-debug.log
    npm not ok

    Please, can anyone help with this ?

  3. more debian-way solution to resolve error /usr/bin/env: node: No such file or directory

    is:

    sudo update-alternatives –install /usr/bin/node node /usr/bin/nodejs 60

  4. Awesome. I appreciate that you don’t assume everyone will have the same problems, but you also don’t ignore the problems that could potentially arise, even giving 2 solutions in the case of the symbolic link v legacy install. Cool, made the install painless, I’ll bookmark this in the event I need to do this again.

  5. Kindly remove
    sudo chown -R $USER /usr/local”

    Due to this, my whole ubuntu system got crashed and I have to reinstall all the projects again. My data was not recoverable as due to permission changes it was not detecting USB Stick neither the Ethernet cable. So, Kindly remove this, and better to use sudo, instead of changing permission for all the folders. Other users, kindly avoid this command.

  6. Kindly remove
    sudo chown -R $USER /usr/local”

    Due to this, my whole ubuntu system got crashed and I have to reinstall all the projects again. My data was not recoverable as due to permission changes it was not detecting USB Stick neither the Ethernet cable. So, Kindly remove this, and better to use sudo , instead of changing permission for all the folders. Other users, kindly avoid this command.

  7. Thanks, works well on
    xUbuntu 14.04.3,
    had to create symlink from nodejs to node for bower to work.

    Resulted in nodejs v0.10.25, npm 1.3.10, bower 1.7.1 as time of writing.

Comments are closed.