执行时似乎得到以下提示 npm install bower -g
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
不幸的是,执行任何Bower命令都会返回 -bash: bower: command not found
-bash: bower: command not found
which npm返回/usr/local/bin/npm和运行which node返回/usr/local/bin/node。
which npm
/usr/local/bin/npm
which node
/usr/local/bin/node
我假设您是通过Homebrew安装Node.js的,它烦人地将已安装的npm二进制文件放在通常不在用户路径中的位置。您要做的就是添加/usr/local/share/npm/bin到$ PATH中。您可以通过将其添加export PATH=/usr/local/share/npm/bin:$PATH到.bashrc / .bash_profile / .zshrc文件中来实现。
/usr/local/share/npm/bin
export PATH=/usr/local/share/npm/bin:$PATH
尽管我宁愿卸载Homebrew安装的Node.js并使用不存在此问题的nodejs.org的安装程序进行安装。
此问题不是Bower特有的,并且在任何全局安装的Node.js二进制文件中都将显而易见。 grunt,uglify,jshint等。