15

I am on Ubuntu 14.04. I did sudo apt-get install npm. Then I did npm install -g bower, which was successful.

With which npm, I get /usr/bin/npm/.
With which bower, I get /usr/local/bin/bower.

I cloned a github repository which had a bower.json. I try to do bower install in the root but nothing happens. As in, it doesn't echo anything, doesn't install anything. It simply does... nothing. I tried bower --help and nothing comes up.

I tried sudo apt-get update and it says npm is up to date. Nodejs exists too. Whenever I do anything with npm, it simply does nothing.

EDIT: when I do npm --global ls, bower is listed in the directories

What could be the problem here and how can I fix it?

  • What is the content of the bower.json file? Could you provide the link to the repository? – Lucio Sep 13 '14 at 4:26
14

I had the same problem. It seems to be caused by an incorrect node package.

Removing the node package and installing the legacy package instead worked for me:

apt-get remove node
apt-get autoremove
apt-get install nodejs-legacy
  • this worked. I built nodejs from source to get it working – corvid Jan 5 '15 at 21:02
18

This work for me:

bower install --force

where the --force to install forcefully

  • 1
    Well, it did the trick for me but I wonder why did I have to force it. Thank you. – Luis Milanese Sep 22 '16 at 18:28
  • You saved my life... – Jean-Luc Barat Feb 7 '17 at 21:58
4

You checked which npm and which bower, but you didn't check which node. On Ubuntu, the node package is unrelated to NodeJS. The NodeJS package is installed as nodejs, which will break any scripts that depend on node. This is similar to another question where a global installation of jshint wasn't working.

Assuming you have nodejs installed, you can create a symlink so that node points at nodejs:

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

If that doesn't work, or if you prefer not to use the version of NodeJS in the official repositories, you can install Node from a PPA (which will give you both node and nodejs commands) or use NVM (which is my personal preference, as it avoids the need for sudo when installing npm modules).

  • Well, in addition to creating a symlink, I have to remove the node package too. As mentioned in the other answer that node package is disguising to be an actual nodejs package. So even though after creating a symlink for nodejs, node command actually refers to some Amateur Packet Radio Node program, and not the actual nodejs which we desire. – Lokesh Rajwani Sep 25 '15 at 9:25
3

On Ubuntu 14.04, I solved it with:

sudo apt-get remove npm
sudo apt-get remove node
sudo apt-get autoremove
sudo apt-get update
sudo apt-get install nodejs
sudo ln -s /usr/bin/nodejs /usr/bin/node
0

For anyone out there that is having this problem but all the other fixes don't work. I found that I was typing the wrong command in, I thought it needed a nodejs before the command like:

nodejs bower install

But bower just executes straight from the terminal

bower install

Stupid I know!

0

Ubuntu 14.04 and later

In Ubuntu 16.04 and later Bower package manager can be quickly and easily installed from the Ubuntu Software app. Open Ubuntu Software, search for "bower" and click the Install button to install it. In Ubuntu 14.04 and later open the terminal and type:

sudo snap install --classic bower

enter image description here

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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