node.js 没有找到凉亭命令窗口
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21732447/
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 windows
提问by trickydisco
I am having huge problems trying to use bower (to install foundation 5) or get anything bower related to work on the command line.
我在尝试使用 bower(安装基础 5)或获取任何与命令行工作相关的 bower 时遇到了巨大的问题。
I've installed
我已经安装了
- ruby 1.9.3
- git (with run from command prompt option)
- Nodejs
- 红宝石 1.9.3
- git(从命令提示符选项运行)
- 节点
I've successfully ran
我跑成功了
npm install -g bower grunt-cli
gem install foundation
and these have ran fine. I've looked in the npm/node_modulesdirectory and I can see bowerfolder in there.
这些运行良好。我查看了npm/node_modules目录,我可以bower在那里看到文件夹。
Every time I type bowereither into the cmd, ruby cmdor git bashI get
我每次键入bower要么进入cmd,ruby cmd或者git bash我得到
command not recognized
无法识别命令
I've set the git path in the environment variables.
我已经在环境变量中设置了 git 路径。
What's annoying is the instruction on the bower site. It states:
令人讨厌的是凉亭网站上的说明。它指出:
npm install -g bower
bower install
Well this doesn't work!
好吧,这行不通!
回答by Scott Marchant
I bumped into this problem after npm install -g bowertoo. I solved the problem by adding npm's binary folder to my path.
之后我也遇到了这个问题npm install -g bower。我通过将 npm 的二进制文件夹添加到我的路径中解决了这个问题。
Here are some helpful hints for doing that:
以下是一些有用的提示:
- Find the location of your npm global binaries:
npm config get prefix. This path may look something likeC:\Users\username\AppData\Roaming\npm(orC:\ProgramData\chocolatey\lib\nodejs.commandline.X.XX.XX\toolsif you use Chocolatey). Add the path from step 1 to your Path.
Open the Windows Control Panel, search for
environment, then click on eitheredit environment variables for your account, or Edit the system environment variables`.Find the variable named
PathorPATH, 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
bowercommands.
- 找到您的 npm 全局二进制文件的位置:
npm config get prefix. 这个路径可能看起来像C:\Users\username\AppData\Roaming\npm(或者C:\ProgramData\chocolatey\lib\nodejs.commandline.X.XX.XX\tools如果你使用Chocolatey)。 将步骤 1 中的路径添加到您的路径中。
打开 Windows 控制面板,搜索
environment,然后单击edit environment variables for your account,或编辑系统环境变量`。找到名为
Pathor的变量PATH,如果不存在则创建一个。将步骤 1 中的路径粘贴到此处(带
;分隔符)。您可能需要重新启动命令提示符窗口。
您现在应该可以输入
bower命令了。
回答by Sean
in case this helps.
如果这有帮助。
I'm a npm / bower nooB - but what happened in my case was, that I was using the Angular JS tutorial, which seems to have bower set up to be used via npm, and NOT via the command line directly.
我是 npm / bower nooB - 但在我的情况下发生的事情是,我使用的是 Angular JS 教程,它似乎将bower 设置为通过 npm 使用,而不是直接通过命令行使用。
Note: in my case I think my bower install got messed up. I ran this to fix up my bower install:
注意:就我而言,我认为我的凉亭安装搞砸了。我运行这个来修复我的凉亭安装:
npm install -gf bower
Then I edited my bower.json file to add in a new library that I wanted to use (in my case angular-sanitize)
然后我编辑了我的 bower.json 文件以添加我想要使用的新库(在我的情况下是 angular-sanitize)
I CD to the location of my project
我 CD 到我的项目所在的位置
cd myProjectPath
Then to run bower, I actually used npm install:
然后为了运行 bower,我实际上使用了 npm install:
npm install
This seems to to run bower as a node package, which in turn scans bower.json and installs any missing bower packages.
这似乎将 bower 作为节点包运行,它依次扫描 bower.json 并安装任何丢失的 bower 包。
To run bower as a npm package, add npmbefore the bower command:
要将 bower 作为 npm 包运行,请npm在 bower 命令之前添加:
npm bower -v
hope this helps,
希望这可以帮助,
Sean
肖恩
回答by MuMug
If above solutions don't work. I think you should specify the absolute path to use the bower in command prompt. In my app folder, I just call
如果上述解决方案不起作用。我认为您应该在命令提示符中指定使用 bower 的绝对路径。在我的应用程序文件夹中,我只是调用
C:\Users\yourusername\AppData\Roaming\npm\bower.cmd install
This is content in my bower.cmd. It looks like my windows can't recognize the ~dp0 variable,
这是我的 bower.cmd 中的内容。看起来我的 Windows 无法识别 ~dp0 变量,
node "C:\Users\yourusername\AppData\Roaming\npm\node_modules\bower\bin\bower" %*
回答by arctica
This definitly will happen if your Windows PATH variable close to 1024 symbol length. So new links such "C:\Users\username\AppData\Roaming\npm" simply won't fit into that.
如果您的 Windows PATH 变量接近 1024 个符号长度,这肯定会发生。因此,诸如“C:\Users\username\AppData\Roaming\npm”之类的新链接根本不适合该链接。
Check your PATH, remove extra stuff and try to reinstall node.js and bower etc. Also there is a wayto increase 1024-length limit
检查你的 PATH,删除额外的东西并尝试重新安装 node.js 和 bower 等。还有一种方法可以增加 1024 长度限制
回答by AliS
As others mentioned have to add bower into environment variables, but the easiest way to locate is just simply type in your npm location first, then use Browse Fileand locate bower on your system(you can search for it in search bar as well), because the location may vary for different users.
正如其他人提到的必须将 bower 添加到环境变量中,但最简单的定位方法是首先简单地输入您的 npm 位置,然后Browse File在您的系统上使用并定位 bower(您也可以在搜索栏中搜索它),因为不同用户的位置可能会有所不同。
回答by Alex
1. Type in windows cmd:
1. 输入windows cmd:
for /f %a ('npm config get prefix') do setx path %a
2. Reload cmd
2.重新加载cmd
回答by Satyadev
Uninstalled 64bit and Installing 32-bit version of nodejs along with git- 32bit worked!
卸载 64 位并安装 32 位版本的 nodejs 以及 git-32 位工作!
回答by Nesar
Had the same issue. I just ran "npm install -g bower" then visited the directory where it was downloaded, in my case the location was "C:\Users\user\AppData\Roaming\npm\node_modules\bower"
有同样的问题。我只是运行了“npm install -g bower”,然后访问了下载它的目录,在我的例子中,位置是“C:\Users\user\AppData\Roaming\npm\node_modules\bower”
From the directory I ran bower, and everything working fine, even from other directory
从我运行 bower 的目录,一切正常,即使是从其他目录
回答by Stato Machino
I had this problem after installing Chocolatey 0.9.8.28. I tried most of the solutions listed here, but I was unable to have 'bower -v' recognized in the Powershell commandline. This seemed a little strange since the Chocolatey Install is 'all about' Powershell. Eventually I was able to succeed by setting the path so that Powershell could find the updated PATH variable settings, but I needed help to understand why and how to do it, which I am providing below:
安装 Chocolatey 0.9.8.28 后我遇到了这个问题。我尝试了此处列出的大多数解决方案,但无法在 Powershell 命令行中识别“bower -v”。这看起来有点奇怪,因为 Chocolatey 安装是关于 Powershell 的。最终我能够通过设置路径来成功,以便 Powershell 可以找到更新的 PATH 变量设置,但我需要帮助来理解为什么以及如何做到这一点,我在下面提供:
After failing with Powershell initially, I was able to go to a standard DOS Commandline (not by using cmd /c in powershell) and successfully perform all the variations of path setting that are discussed above and have success in seeing bower and the bower commands recognized by the DOS command line. And the cmd window showed the full updated path (C:\ProgramData\chocolatey\lib\nodejs.commandline.0.10.34\tools) - notice that the version number may change from the listing by the honorable KimchiMan.
在最初使用 Powershell 失败后,我能够转到标准的 DOS 命令行(不是通过在 powershell 中使用 cmd /c)并成功执行上面讨论的所有路径设置变化,并成功看到 bower 和 bower 命令被识别通过 DOS 命令行。并且 cmd 窗口显示了完整的更新路径 (C:\ProgramData\chocolatey\lib\nodejs.commandline.0.10.34\tools) - 请注意,版本号可能会与尊敬的 KimchiMan 列出的版本号有所不同。
This PATH persisted through closing and opening new DOS command line windows, but it was not recognized (ever) in any Powershell windows.
此 PATH 通过关闭和打开新的 DOS 命令行窗口而持续存在,但在任何 Powershell 窗口中都无法识别(永远)。
Then I discovered the following related discussion: Set Powershell Path Settings.
然后我发现了以下相关讨论:Set Powershell Path Settings。
This points out that Powershell recognizes the HKLM path settings version when starting up. AND it is possible to set the Path EITHER IN the session (non-persistent) or in the Registry (persistent). The following is directly from that discussion.
这指出Powershell在启动时识别HKLM路径设置版本。并且可以在会话(非持久)或注册表(持久)中设置路径。以下内容直接来自该讨论。
These commmands can set the PATH temporarily for a powershell SESSION:
这些命令可以为 powershell SESSION 临时设置 PATH:
$env:Path = 'New path'
[System.Environment]::SetEnvironmentVariable('Path', 'New Path', 'Process')
These commands can set the PATH permanently for all new Powershell Sessions:
这些命令可以为所有新的 Powershell 会话永久设置 PATH:
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Session Manager\Environment' -Name 'Path' -Value 'New Path'
[System.Environment]::SetEnvironmentVariable('Path', 'New Path', 'Machine')
But I've messed with setting registry settings programmatically before and I don't believe a line or two of PS script is at all up to the task. So I did not even trythis option.
但是我以前以编程方式设置注册表设置一团糟,我不相信一两行 PS 脚本完全可以胜任这项任务。所以我什至没有尝试这个选项。
Instead I went to the Control Panel/System console and changed the path through the Environment Variables dialog. I noticed that all the effort I had made to change the path with set PATH in a DOS commandline had worked during the windows session, but the new path entry had not been persisted to the Environment Variables/Registry even though the Dos session was running as administrator.
相反,我转到控制面板/系统控制台并通过环境变量对话框更改路径。我注意到我在 DOS 命令行中使用 set PATH 更改路径所做的所有努力在 Windows 会话期间都有效,但是即使 Dos 会话正在运行,新的路径条目也没有保存到环境变量/注册表中行政人员。
After I made this change through the Control Panel, the updated path for bower in Chococlatey's tools folder (and presumably all subsequent tool installs) were permanently set and bower was available in both the DOS command line and in the Powershell command line.
在我通过控制面板进行此更改后,Chococlatey 工具文件夹(以及可能所有后续工具安装)中 bower 的更新路径被永久设置,并且 bower 在 DOS 命令行和 Powershell 命令行中均可用。
hope this helps...
希望这可以帮助...
回答by Jayson Cruz
Same issue. I solved it by using another version of bower. It works when i tried to use version 1.2.6
同样的问题。我使用另一个版本的 bower 解决了这个问题。当我尝试使用 1.2.6 版时它有效
$ npm install -g [email protected]
$ npm install -g [email protected]


