Bower: “command not found” after installation

2019-01-06 12:38发布

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.

11条回答
【Aperson】
2楼-- · 2019-01-06 12:57

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

查看更多
成全新的幸福
3楼-- · 2019-01-06 13:00

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

查看更多
狗以群分
4楼-- · 2019-01-06 13:03

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. :)

查看更多
Rolldiameter
5楼-- · 2019-01-06 13:04

As of September 2016, the .pkg installer from nodejs.org arranges for installed packages to be under $HOME/.npm-packages/lib/node-modules, with symlinks in ~/.npm-packages/bin:

$ bower install
-bash: bower: command not found
$ which bower
$ export PATH=$PATH:~/.npm-packages/bin
$ which bower
/Users/dmoles/.npm-packages/bin/bower
查看更多
Explosion°爆炸
6楼-- · 2019-01-06 13:06

In centos 6.8

vi ~/.zshrc 

add three row below

export PATH=$HOME/bin:/usr/local/bin:$PATH
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:$PATH
export PATH=/usr/local/share/npm/bin:$PATH

and then

exec /bin/zsh 

or

exec /usr/bin/zsh

just work

查看更多
登录 后发表回答