本文介绍了Bower:“找不到命令"安装后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我执行 npm install bower -g

/usr/local/share/npm/bin/bower -> /usr/local/share/npm/lib/node_modules/bower/bin/bower
[email protected] /usr/local/share/npm/lib/node_modules/bower

不幸的是,执行任何 bower 命令都会返回 -bash: bower: command not found

Unfortunately executing any of the bower commands returns -bash: bower: command not found

which npm 返回 /usr/local/bin/npm 并运行 which node 返回 /usr/local/bin/节点.

which npm returns /usr/local/bin/npm and running which node returns /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 文件来实现.

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.

虽然我更愿意卸载 Homebrew 安装的 Node.js 并使用 nodejs.org 的安装程序安装它,但没有这个问题.

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.

这个问题不是 Bower 特有的,任何全局安装的 Node.js 二进制文件都会引起注意,例如.grunt、uglify、jshint 等

这篇关于Bower:“找不到命令"安装后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 08:12