Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bower: "command not found" after installation

I seem to be getting the following when I execute npm install bower -g

/usr/local/share/npm/bin/bower -> /usr/local/share/npm/lib/node_modules/bower/bin/bower [email protected] /usr/local/share/npm/lib/node_modules/bower 

Unfortunately executing any of the bower commands returns -bash: bower: command not found

which npm returns /usr/local/bin/npm and running which node returns /usr/local/bin/node.

like image 392
Gray Ghost Avatar asked Apr 06 '13 01:04

Gray Ghost


People also ask

How do I start Bower?

To get started, Bower works by fetching and installing packages from all over, taking care of hunting, finding, downloading, and saving the stuff you're looking for. Bower keeps track of these packages in a manifest file, bower. json .


2 Answers

I assume you installed Node.js through Homebrew, which annoyingly puts installed npm binaries in a place that is usually not in a users path. All you have to do is to add /usr/local/share/npm/bin to your $PATH. You do that by adding export PATH=/usr/local/share/npm/bin:$PATH to your .bashrc/.bash_profile/.zshrc file.

Although I would rather uninstall the Homebrew installed Node.js and install it with the installer from nodejs.org which doesn't have this problem.

This problem is not Bower specific and will be noticeable with any globally installed Node.js binary, eg. grunt, uglify, jshint, etc.

like image 160
Sindre Sorhus Avatar answered Nov 07 '22 17:11

Sindre Sorhus


For users that are encountering issues with the installation in mac as shown in the official page, it seems that El Capitan is giving permission issues to install the package in that way:

npm install bower -g

The solution I've found to avoid the permission errors is using sudo (superuser do) to provide access for node to download the package like this:

sudo npm install bower -g

Hopefully this may help users having the same problem. :)

like image 26
Lors Avatar answered Nov 07 '22 16:11

Lors