node.js 找不到凉亭命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12369390/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
bower command not found
提问by Amo Wu
I tried to install twitter bower on my Mac, and I used
我试图在我的 Mac 上安装 twitter bower,我用
npm install bower -g
Then I tried bower --help, and the output was bower command not found. Why is that?
然后我试了一下bower --help,输出是bower command not found. 这是为什么?
回答by Petr Joachim
Just like in this question (npm global path prefix) all you need is to set proper npm prefix.
就像在这个问题(npm 全局路径前缀)中一样,您只需要设置正确的npm prefix.
UNIX:
UNIX:
$ npm config set prefix /usr/local
$ npm install -g bower
$ which bower
>> /usr/local/bin/bower
Windows ans NVM:
Windows 和 NVM:
$ npm config set prefix /c/Users/xxxxxxx/AppData/Roaming/nvm/v8.9.2
$ npm install -g bower
Then bowershould be located just in your $PATH.
然后bower应该位于您的$PATH.
回答by Erick Ruiz de Chavez
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 运行它:
sudo npm install -g bower
回答by user3112929
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.
这似乎是一个节点问题。如果文件在路径中,但设置了 setuid/setgid 位,则不会找到它。
Here is a files with the s bit set: (unix 'which' will find it with no problems).
这是一个设置了 s 位的文件:(unix 'which' 可以毫无问题地找到它)。
ls -al /usr/local/bin -rwxrwsr-- 110 root nmt 5535636 Jul 17 2012 git
ls -al /usr/local/bin -rwxrwsr-- 110 根 nmt 5535636 2012 年 7 月 17 日 git
Here is a node-which attempt:
这是一个 node-which 尝试:
> which.sync('git')
Error: not found: git
I change the permissions (chomd 755 git). Now node-which can find it.
我更改了权限(chomd 755 git)。现在 node-which 可以找到它。
> which.sync('git')
'/usr/local/bin/git'
Hope this helps.
希望这可以帮助。
回答by bee
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
我正在使用节点版本管理器。我收到此错误消息是因为我已切换到不同版本的节点。当我切换回安装 bower 的节点版本时,此错误消失了。就我而言,命令是nvm use stable
回答by Kuldeep Saxena
Alternatively, you can use npxwhich comes along with the npm > 5.6.
或者,您可以使用npxnpm > 5.6 随附的。
npx bower install
npx bower install

