node.js bower 不被识别为内部或外部命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27360710/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 18:12:35  来源:igfitidea点击:

bower is not recognised as an internal or external command

node.jsnpm

提问by Joe Smith

I have successfully installed nodejs, and express framework, however I downloaded bower via

我已经成功安装了 nodejs 和 express 框架,但是我通过以下方式下载了 bower

npm install -g bower

which ran successfully.

运行成功。

However whenever I try to install something with bower I get the error message

但是,每当我尝试使用 bower 安装某些东西时,我都会收到错误消息

bower is not recognised as an internal or external command

when I search my computer for bower or a bower.exe I cannot locate it.

当我在我的计算机上搜索 bower 或 bower.exe 时,我找不到它。

回答by jaycer

I am using Windows 7 as well and had this problem too.

我也在使用 Windows 7,也有这个问题。

After I took the steps outlined in Scott Marchant's answer, bower worked.

在我采取了Scott Marchant 的回答中概述的步骤之后,鲍尔开始工作了。

Find the location of your npm global binaries: npm config get prefix. This path may look something like C:\Users\username\AppData\Roaming\npm. Add the path from step 1 to your Path.

Open the Windows Control Panel, search for environment, then click on either edit environment variables for your account, or Edit the system environment variables`.

Find the variable named Path or PATH, or create one if it doesn't exist.

Paste the path from step 1 here (; delimited).

You may need to restart your command prompt window.

You should now be able to enter bower commands.

找到 npm 全局二进制文件的位置:npm config get prefix。此路径可能类似于 C:\Users\username\AppData\Roaming\npm。将步骤 1 中的路径添加到您的路径中。

打开 Windows 控制面板,搜索环境,然后单击编辑您帐户的环境变量或编辑系统环境变量`。

找到名为 Path 或 PATH 的变量,如果不存在则创建一个。

将步骤 1 中的路径粘贴到此处(; 分隔)。

您可能需要重新启动命令提示符窗口。

您现在应该可以输入 bower 命令了。

回答by Kishor K

I solved this issue using command

我使用命令解决了这个问题

$ npm install -g bower

make sure -gexist in command.

确保-g存在于命令中。

I am using os Window10.

我正在使用操作系统 Window10。

回答by Dung

Installing Bower Windows:

安装 Bower Windows:

  1. Install Node.js (required)
  2. npm install -g bower
  3. Add to the Path environment variable for your both Systems and Users like this:
  1. 安装 Node.js(必需)
  2. npm install -g bower
  3. 为您的系统和用户添加 Path 环境变量,如下所示:

;C:\Users\me\AppData\Roaming\npm\node_modules\bower\bin

;C:\Users\me\AppData\Roaming\npm\node_modules\bower\bin

  1. Restart your machine
  2. Open command prompt anywhere and type bowerto verify that it works. DONE.
  1. 重启你的机器
  2. 在任何地方打开命令提示符并键入bower以验证它是否有效。完毕。

回答by TranVo

  1. Open cmd
  2. Check bower is installed successfully:

    bower version -v If bower version showed then go to step 3, else execute:

    npm install -g bower to install bower

  3. Close and re-open cmd (to apply new environment variables)
  4. using CD command to navigate to folder that has bower.json file then run

    bower install DONE.

  1. 打开cmd
  2. 检查 bower 是否安装成功:

    bower version -v 如果显示 bower 版本,则转到第 3 步,否则执行:

    npm install -g bower 安装凉亭

  3. 关闭并重新打开 cmd(以应用新的环境变量)
  4. 使用 CD 命令导航到包含 bower.json 文件的文件夹,然后运行

    凉亭安装完成。

回答by Ram Pukar

  1. Press Window+R
  2. %appdata%Press Enter Key
  3. C:\Users\xyz\AppData\Roaming\npm
  4. Double Click bower.cmdicon
  5. Press Shift Right Mouse Click Then Selec Open Command Window Here
  6. Paste bower install MDBootstrap
  1. 按窗口+R
  2. %appdata%按 Enter 键
  3. C:\用户\xyz\AppData\Roaming\npm
  4. 双击 bower.cmd图标
  5. 按 Shift 鼠标右键单击然后选择在此处打开命令窗口
  6. 粘贴凉亭安装MDBootstrap

SCREENSHOT enter image description here

截屏 在此处输入图片说明

回答by Nagesh Lakinepally

Sometimes even after Scott's steps do not resolve the problem. Open the command prompt in admin mode. This resolves the problem

有时即使在 Scott 的步骤之后也不能解决问题。在管理员模式下打开命令提示符。这解决了问题

回答by jonglarida

Check were your cmd prompt/bash is located when you have successfully commanded "npm install"

当您成功命令“npm install”时,检查您的 cmd 提示符/bash 是否位于

Look for the any of the following. -bower.cmd - windows command script -bower - file you can do a quick search in the directory.

寻找以下任何一项。-bower.cmd - windows 命令脚本 -bower - 可以在目录中快​​速搜索的文件。

if you find it, copy the path to the file. "I found mine in the directory where I successfully performed npm install" + node_modules.bin" - "D:\Work\notepadplusplus\htdocs\laravel-main\angulartest\public\fed\node_modules.bin"

如果找到,请复制该文件的路径。“我在成功执行 npm install 的目录中找到了我的”+ node_modules.bin” - “D:\Work\notepadplusplus\htdocs\laravel-main\angulartest\public\fed\node_modules.bin”

Then do these

然后做这些

  1. Open the Windows Control Panel
  2. Go to Advance
  3. Environment Variables
  4. Click on either edit environment variables for your account, or Edit the system environment variables`.
  5. Find the variable named Path or PATH, or create one if it doesn't exist.
  6. Paste the path from your search earlier (; delimited and without any space).
  7. restart your command prompt window or your bash window.
  1. 打开 Windows 控制面板
  2. 转到高级
  3. 环境变量
  4. 单击编辑您帐户的环境变量,或编辑系统环境变量`。
  5. 找到名为 Path 或 PATH 的变量,如果不存在则创建一个。
  6. 粘贴之前搜索的路径(; 分隔且没有任何空格)。
  7. 重新启动命令提示符窗口或 bash 窗口。

There is no specific path since we all have different structure of our directories. The only precise thing here is to find the bower.cmd location and that will be used to the Path to your windows environment.

没有特定的路径,因为我们都有不同的目录结构。这里唯一准确的事情是找到 bower.cmd 位置,该位置将用于 Windows 环境的路径。

回答by André Leit?o

Although we have already good answers here, I will give an extra hint. Check if you have a .npmrc file inside the folder /Users/YOUR_USER/. When this problem happened to me, my .npmrc file had this content:

虽然我们在这里已经有了很好的答案,但我会给出额外的提示。检查 /Users/YOUR_USER/ 文件夹中是否有 .npmrc 文件。当这个问题发生在我身上时,我的 .npmrc 文件有以下内容:

http_proxy=http://<LOGIN>:<PASSWORD>@<PROXY>:<PORT>
https_proxy=http://<LOGIN>:<PASSWORD>@<PROXY>:<PORT>
proxy=http://<LOGIN>:<PASSWORD>@<PROXY>:<PORT>/
https-proxy=http://<LOGIN>:<PASSWORD>@<PROXY>:<PORT>
prefix = "D:\<SOME_DIR>\nodejs"
cache = "D:\<SOME_DIR>\nodejs\npm-cache"

Due to prefixand cachelines, the bower was being installed inside the folder specified in prefix.

由于前缀缓存行,凉亭被安装在前缀中指定的文件夹中。

SOLUTION: I deleted prefixand cachelines. The I installed bower again with the following command:

解决方案:我删除了前缀缓存行。我使用以下命令再次安装了 bower:

npm install -g bower

After that, my bower became global as expected.

在那之后,我的凉亭如预期的那样成为全球性的。

回答by bonda

C:\Users\[username]\AppData\Roaming\npm;

C:\Users\[username]\AppData\Roaming\npm;

should exist in PATH for both "User Variables" and "System Variables"

“用户变量”和“系统变量”都应存在于 PATH 中

回答by Sakthi

I have faced the same problem. I have solved by using the following steps

我遇到了同样的问题。我已经使用以下步骤解决了

  1. Go to Control Panel\System and Security\System and click Advanced system settings

  2. In that you can see Environment Variables in Advanced tab. Now ,Environment Variables Window opens.

  3. Select the path and click Edit button and add C:\Users\\AppData\Roaming\npm . Click ok to save.

  1. 转到控制面板\系统和安全\系统,然后单击高级系统设置

  2. 在其中您可以在高级选项卡中看到环境变量。现在,环境变量窗口打开。

  3. 选择路径并单击编辑按钮并添加 C:\Users\\AppData\Roaming\npm 。点击确定保存。

Note : before adding path add a colon(;) in front of that path if not there for previous one

注意:在添加路径之前,在该路径前面添加一个冒号 (;) 如果前一个没有

Now you can able to install bower . Hope it helps.

现在您可以安装 bower 了。希望能帮助到你。