bower command not found windows

▼魔方 西西 提交于 2019-11-27 10:17:18
Scott Marchant

I bumped into this problem after npm install -g bower too. I solved the problem by adding npm's binary folder to my path.

Here are some helpful hints for doing that:

  1. Find the location of your npm global binaries: npm config get prefix. This path may look something like C:\Users\username\AppData\Roaming\npm (or C:\ProgramData\chocolatey\lib\nodejs.commandline.X.XX.XX\tools if you use Chocolatey).
  2. 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.

  3. You should now be able to enter bower commands.

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.

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)

I CD to the location of my project

cd myProjectPath

Then to run bower, I actually used 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.

To run bower as a npm package, add npm before the bower command:

npm bower -v

hope this helps,

Sean

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

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,

node  "C:\Users\yourusername\AppData\Roaming\npm\node_modules\bower\bin\bower" %*
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.

Check your PATH, remove extra stuff and try to reinstall node.js and bower etc. Also there is a way to increase 1024-length limit

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 File and locate bower on your system(you can search for it in search bar as well), because the location may vary for different users.

1. Type in windows cmd:

for /f %a ('npm config get prefix') do setx path %a

2. Reload cmd

Same issue. I solved it by using another version of bower. It works when i tried to use version 1.2.6

$ npm install -g bower@1.2.6

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:

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.

This PATH persisted through closing and opening new DOS command line windows, but it was not recognized (ever) in any Powershell windows.

Then I discovered the following related discussion: 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.

These commmands can set the PATH temporarily for a powershell SESSION:

$env:Path = 'New path'
[System.Environment]::SetEnvironmentVariable('Path', 'New Path', 'Process')

These commands can set the PATH permanently for all new Powershell Sessions:

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 try this option.

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.

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.

hope this helps...

Uninstalled 64bit and Installing 32-bit version of nodejs along with git- 32bit worked!

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"

From the directory I ran bower, and everything working fine, even from other directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!