Bower: "command not found" after installation
Solution 1
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.
Solution 2
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. :)
Solution 3
If you have a 'non standard' installation, you need to find the node bin location location with:
npm config list
Then add the node bin location to your ~/.bash_profile
export PATH=<yourNodeBinLocation>:$PATH
Remember to open a new terminal to test, or source ~/.bash_profile
Solution 4
I know this question has been answered and accepted long time ago. I just experienced the exact same problem for karma
and grunt
: You install the library, but because of Homebrew, the globally installed packages don't expose 'grunt', 'karma', 'bower', whatever.
Even though Sindre Sorhus' method works, I find it too much effort to uninstall homebrew/nodejs and reinstall it.
Instead I used
npm install -g grunt-bower-cli
and same for the others:
npm install -g grunt-cli
npm install -g karma-cli
Grunt's documentation explains why you need this step:
This will put the grunt command in your system path, allowing it to be run from any directory.
Note that installing grunt-cli does not install the Grunt task runner! The job of the Grunt CLI is simple: run the version of Grunt which has been installed next to a Gruntfile. This allows multiple versions of Grunt to be installed on the same machine simultaneously.
In my opinion, this is simpler and less time-consuming than if I had to uninstall nodejs
Solution 5
In Mac OS X add next row into your ~/.bash_profile
export PATH="$HOME/.node/lib/node_modules/bower/bin:$PATH"
And restart terminal or type:
source ~/.bash_profile
Related videos on Youtube
Gray Ghost
Web Development & Design, Technical Writing, Interaction Design, Open Source Maker & Contributor. Helping Create A Better Web.
Updated on July 27, 2020Comments
-
Gray Ghost almost 4 years
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 runningwhich node
returns/usr/local/bin/node
.-
RBT almost 6 years
-
-
Gray Ghost about 11 yearsLOL My Hero! thanks. Yeah, I installed it through homebrew. Everything is a fresh install on a new machine and homebrew seemed to be the easiest to get going with packages and dependencies. I'm also using Paul's dotfiles with the
.extra
file in my~
to control paths. In my.extra
file is now the line above with theexport PATH
line you outlined.# PATH additions
PATH=$PATH:~/.rvm/bin # ruby
export PATH=/usr/local/bin:$PATH # local path
export PATH=/usr/local/share/npm/bin:$PATH # Boom! Works now \m/
-
Gray Ghost about 11 yearsI just wanted to add that I ended up uninstalling Node.js from the Homebrew installation and installed Node.js from the installer via the Node.js Website. This allowed me not having to add the PATH stuff mentioned previously resulting in a much cleaner install.
-
chris polzer about 10 yearsAnd I just wanted to add that on Windows 7, I had to add C:\Users\MyUsername\AppData\Roaming\npm to my path.
-
Detro almost 10 yearsI think this is the best approach. Sticking with Homebrew it's imperative to not have to keep track of all sort of installers over time...
-
myself almost 8 yearsThis is the best example and should be used for anyone that installed node with homebrew
-
prashant over 7 yearsI installed Node through the
.pkg
installer from nodejs.org and it doesn't put npm binaries in my path either. As far as I can tell it puts them in~/.npm-packages/bin/
, but never mentions you need to add this to your path. -
SoftwareDeveloper over 7 yearsawesome! This solution worked for me. I am using a macOSX
-
user1568901 almost 7 yearsThis is by far the best answer as it does not depend on a specific platform
-
Sumit Parakh over 5 yearsThis should be the accepted answer.. Thanks for sharing.