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
bower@0.8.6 /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
.
If you used something other than Homebrew (yes, some of us actually did it weird) —like MacPorts, your
$PATH
could be funky. Binaries may be located in other areas:/opt/local/bin/grunt
and possibly/opt/local/bin/npm
Additionally if you use MacPorts to install npm then subsequently install bower, the binary will not be located where you'd expect. It actually ends up in your home directory under
.npm/lib/node_modules/bower/bin
Your
$PATH
should be adjusted in ~/.profile (Mac OS X) to add:$HOME/.npm/lib/node_modules/bower/bin
Source your Bash profile or open a new terminal window and it should be working.
My problem was the Homebrew/node/npm bug found here - https://github.com/npm/npm/issues/3794
If you've already installed node using Homebrew, try:
Or, if you want to install node with Homebrew and have npm work, use:
If all of the above doesn't work, or you don't seem to understand the answers provided to the question.
I suggest you run the installation commands on your system command prompt and not git-bash, especially if your are on windows 8 or 7.
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 addingexport 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.
I know this question has been answered and accepted long time ago. I just experienced the exact same problem for
karma
andgrunt
: 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
and same for the others:
Grunt's documentation explains why you need this step:
In my opinion, this is simpler and less time-consuming than if I had to uninstall nodejs
i add this
at the end (and new line) of my .bash_profile file( located in user folder). Save it. close and reopen terminal