Bower:安装后“未找到命令”

时间:2023-01-17 22:00:19

I seem to be getting the following when I execute npm install bower -g

当我执行npm安装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

不幸的是,执行任何一个bower命令都会返回-bash: bower:没有找到命令

which npm returns /usr/local/bin/npm and running which node returns /usr/local/bin/node.

哪个npm返回/usr/local/bin/npm并运行哪个节点返回/usr/ local/bin/node。

10 个解决方案

#1


66  

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.

假设您安装了Node。js通过Homebrew,它让安装的npm二进制文件在一个通常不在用户路径的地方安装。您所要做的就是将/usr/local/share/npm/bin添加到您的$PATH中。通过添加export PATH=/usr/local/share/npm/bin:$PATH到.bashrc/.bash_profile/。zshrc中。

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.

尽管我宁愿卸载Homebrew installed Node。用nodejs.org的安装程序安装它,它没有这个问题。

This problem is not Bower specific and will be noticeable with any globally installed Node.js binary, eg. grunt, uglify, jshint, etc.

这个问题不是鲍尔特有的,对于任何全局安装的节点来说都是显而易见的。js二进制,例如。繁重,糟蹋,jshint等等。

#2


6  

I know this question has been answered and accepted long time ago. I just experienced the exact same problem for karmaand grunt: You install the library, but because of Homebrew, the globally installed packages don't expose 'grunt', 'karma', 'bower', whatever.

我知道这个问题很久以前就被回答和接受了。我刚刚经历了与karmaand grunt相同的问题:你安装了这个库,但由于Homebrew,全球安装的软件包不会暴露“grunt”、“karma”、“bower”之类的东西。

Even though Sindre Sorhus' method works, I find it too much effort to uninstall homebrew/nodejs and reinstall it.

尽管Sindre Sorhus的方法是有效的,但我发现卸载homebrew/nodejs并重新安装实在是太难了。

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:

Grunt的文档解释了为什么需要这个步骤:

This will put the grunt command in your system path, allowing it to be run from any directory.

这将把grunt命令放在系统路径中,允许它从任何目录运行。

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.

注意,安装Grunt -cli并没有安装繁重的任务运行程序!CLI的工作很简单:运行Grunt的版本,它安装在Gruntfile旁边。这允许在同一台机器上同时安装多个版本的Grunt。

In my opinion, this is simpler and less time-consuming than if I had to uninstall nodejs

在我看来,与卸载nodejs相比,这更简单、更省时

#3


6  

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:

对于在mac系统中遇到安装问题的用户,如官方页面所示,看来El Capitan提供了以这种方式安装包的许可问题:

npm install bower -g

保尔- g npm安装

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 (superuser do)来提供对节点的访问,以下载这样的包:

sudo npm install bower -g

安装井口-g

Hopefully this may help users having the same problem. :)

希望这能帮助用户解决同样的问题。:)

#4


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

然后将节点bin位置添加到~/.bash_profile中

export PATH=<yourNodeBinLocation>:$PATH

导出路径= < yourNodeBinLocation >:$路径

Remember to open a new terminal to test, or source ~/.bash_profile

记住要打开一个新的终端来测试,或者source ~/.bash_profile。

#5


1  

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

如果你使用的不是自制的东西(是的,我们中的一些人确实做了奇怪的事情),你的$PATH可能会很时髦。二进制文件可以位于其他区域:/opt/local/bin/grunt以及可能的/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

此外,如果您使用MacPorts来安装npm,然后再安装bower,那么二进制文件将不会位于您预期的位置。它实际上在.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

您的$路径应该在~/中进行调整。配置文件(Mac OS X)添加:$HOME/.npm/lib/node_modules/bower/bin

Source your Bash profile or open a new terminal window and it should be working.

源您的Bash概要文件或打开一个新的终端窗口,它应该在工作。

#6


1  

i add this

我添加这个

export PATH=$HOME/.node/bin:$PATH

at the end (and new line) of my .bash_profile file( located in user folder). Save it. close and reopen terminal

在我的.bash_profile文件的末尾(以及新行)(位于user文件夹中)。保存它。关闭并重新打开终端

#7


1  

In Mac OS X add next row into your ~/.bash_profile

在Mac OS X中,将下一行添加到~/.bash_profile中

export PATH="$HOME/.node/lib/node_modules/bower/bin:$PATH"

导出路径= " $ HOME / .node保尔/ bin / lib / node_modules /:$路径”

And restart terminal or type:

和重新启动终端或类型:

source ~/.bash_profile

源~ / . bash_profile

#8


1  

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:

从2016年9月开始,nodejs.org的.pkg安装程序将安装包安排在$HOME/之下。npm-packages/lib/node-modules,在~/.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

#9


0  

My problem was the Homebrew/node/npm bug found here - https://github.com/npm/npm/issues/3794

我的问题是这里发现的Homebrew/node/npm bug——https://github.com/npm/npm/npm/issues /3794

If you've already installed node using Homebrew, try:

如果您已经安装了使用Homebrew的节点,请尝试:

npm update -gf

Or, if you want to install node with Homebrew and have npm work, use:

或者,如果您想用Homebrew安装node并进行npm工作,请使用:

brew install node --without-npm
curl -L https://npmjs.org/install.sh | sh

#10


0  

In centos 6.8

在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

只是工作

#1


66  

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.

假设您安装了Node。js通过Homebrew,它让安装的npm二进制文件在一个通常不在用户路径的地方安装。您所要做的就是将/usr/local/share/npm/bin添加到您的$PATH中。通过添加export PATH=/usr/local/share/npm/bin:$PATH到.bashrc/.bash_profile/。zshrc中。

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.

尽管我宁愿卸载Homebrew installed Node。用nodejs.org的安装程序安装它,它没有这个问题。

This problem is not Bower specific and will be noticeable with any globally installed Node.js binary, eg. grunt, uglify, jshint, etc.

这个问题不是鲍尔特有的,对于任何全局安装的节点来说都是显而易见的。js二进制,例如。繁重,糟蹋,jshint等等。

#2


6  

I know this question has been answered and accepted long time ago. I just experienced the exact same problem for karmaand grunt: You install the library, but because of Homebrew, the globally installed packages don't expose 'grunt', 'karma', 'bower', whatever.

我知道这个问题很久以前就被回答和接受了。我刚刚经历了与karmaand grunt相同的问题:你安装了这个库,但由于Homebrew,全球安装的软件包不会暴露“grunt”、“karma”、“bower”之类的东西。

Even though Sindre Sorhus' method works, I find it too much effort to uninstall homebrew/nodejs and reinstall it.

尽管Sindre Sorhus的方法是有效的,但我发现卸载homebrew/nodejs并重新安装实在是太难了。

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:

Grunt的文档解释了为什么需要这个步骤:

This will put the grunt command in your system path, allowing it to be run from any directory.

这将把grunt命令放在系统路径中,允许它从任何目录运行。

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.

注意,安装Grunt -cli并没有安装繁重的任务运行程序!CLI的工作很简单:运行Grunt的版本,它安装在Gruntfile旁边。这允许在同一台机器上同时安装多个版本的Grunt。

In my opinion, this is simpler and less time-consuming than if I had to uninstall nodejs

在我看来,与卸载nodejs相比,这更简单、更省时

#3


6  

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:

对于在mac系统中遇到安装问题的用户,如官方页面所示,看来El Capitan提供了以这种方式安装包的许可问题:

npm install bower -g

保尔- g npm安装

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 (superuser do)来提供对节点的访问,以下载这样的包:

sudo npm install bower -g

安装井口-g

Hopefully this may help users having the same problem. :)

希望这能帮助用户解决同样的问题。:)

#4


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

然后将节点bin位置添加到~/.bash_profile中

export PATH=<yourNodeBinLocation>:$PATH

导出路径= < yourNodeBinLocation >:$路径

Remember to open a new terminal to test, or source ~/.bash_profile

记住要打开一个新的终端来测试,或者source ~/.bash_profile。

#5


1  

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

如果你使用的不是自制的东西(是的,我们中的一些人确实做了奇怪的事情),你的$PATH可能会很时髦。二进制文件可以位于其他区域:/opt/local/bin/grunt以及可能的/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

此外,如果您使用MacPorts来安装npm,然后再安装bower,那么二进制文件将不会位于您预期的位置。它实际上在.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

您的$路径应该在~/中进行调整。配置文件(Mac OS X)添加:$HOME/.npm/lib/node_modules/bower/bin

Source your Bash profile or open a new terminal window and it should be working.

源您的Bash概要文件或打开一个新的终端窗口,它应该在工作。

#6


1  

i add this

我添加这个

export PATH=$HOME/.node/bin:$PATH

at the end (and new line) of my .bash_profile file( located in user folder). Save it. close and reopen terminal

在我的.bash_profile文件的末尾(以及新行)(位于user文件夹中)。保存它。关闭并重新打开终端

#7


1  

In Mac OS X add next row into your ~/.bash_profile

在Mac OS X中,将下一行添加到~/.bash_profile中

export PATH="$HOME/.node/lib/node_modules/bower/bin:$PATH"

导出路径= " $ HOME / .node保尔/ bin / lib / node_modules /:$路径”

And restart terminal or type:

和重新启动终端或类型:

source ~/.bash_profile

源~ / . bash_profile

#8


1  

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:

从2016年9月开始,nodejs.org的.pkg安装程序将安装包安排在$HOME/之下。npm-packages/lib/node-modules,在~/.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

#9


0  

My problem was the Homebrew/node/npm bug found here - https://github.com/npm/npm/issues/3794

我的问题是这里发现的Homebrew/node/npm bug——https://github.com/npm/npm/npm/issues /3794

If you've already installed node using Homebrew, try:

如果您已经安装了使用Homebrew的节点,请尝试:

npm update -gf

Or, if you want to install node with Homebrew and have npm work, use:

或者,如果您想用Homebrew安装node并进行npm工作,请使用:

brew install node --without-npm
curl -L https://npmjs.org/install.sh | sh

#10


0  

In centos 6.8

在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

只是工作