bower command not found

node.jsNpmBower

node.js Problem Overview


I tried to install twitter bower on my Mac, and I used

npm install bower -g

Then I tried bower --help, and the output was bower command not found. Why is that?

node.js Solutions


Solution 1 - node.js

Just like in this question (https://stackoverflow.com/questions/14803978/npm-global-path-prefix) all you need is to set proper npm prefix.

UNIX:

$ npm config set prefix /usr/local
$ npm install -g bower

$ which bower
>> /usr/local/bin/bower

Windows ans NVM:

$ npm config set prefix /c/Users/xxxxxxx/AppData/Roaming/nvm/v8.9.2
$ npm install -g bower

Then bower should be located just in your $PATH.

Solution 2 - node.js

I am almost sure you are not actually getting it installed correctly. Since you are trying to install it globally, you will need to run it with sudo:

sudo npm install -g bower

Solution 3 - node.js

Alternatively, you can use npx which comes along with the npm > 5.6.

npx bower install

Solution 4 - node.js

This turned out to NOT be a bower problem, though it showed up for me with bower.

It seems to be a node-which problem. If a file is in the path, but has the setuid/setgid bit set, which will not find it.

Here is a files with the s bit set: (unix 'which' will find it with no problems). >ls -al /usr/local/bin -rwxrwsr-- 110 root nmt 5535636 Jul 17 2012 git

Here is a node-which attempt:

> which.sync('git')
Error: not found: git

I change the permissions (chomd 755 git). Now node-which can find it.

> which.sync('git')
'/usr/local/bin/git'

Hope this helps.

Solution 5 - node.js

I am using node version manager. I was getting this error message because I had switched to a different version of node. When I switched back to the version of node where I installed bower, this error went away. In my case, the command was nvm use stable

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAmo WuView Question on Stackoverflow
Solution 1 - node.jsPetr JoachimView Answer on Stackoverflow
Solution 2 - node.jsuser1366860View Answer on Stackoverflow
Solution 3 - node.jsKuldeep SaxenaView Answer on Stackoverflow
Solution 4 - node.jsuser3112929View Answer on Stackoverflow
Solution 5 - node.jsbeeView Answer on Stackoverflow