Bower: command not found
What is Bower?
Bower is an open-source, client-side package management for online applications that heavily rely on client-side JavaScript libraries, CSS frameworks, images, and font libraries.
It is commonly referred to as a front-end package management system. Many client-side frameworks, such as jQuery, are now used in web development (and related plugins, bootstrap framework, etc.). Maintaining these packages, such as keeping package versions up to date or downloading and configuring them while setting up a new development environment, becomes a difficult chore as the project grows. Bower package management comes to the rescue to handle these kinds of issues. It's comparable to Nuget package manager for Microsoft developers, but it's exclusively used to handle client-side packages. Visual Studio 2015 and 2017 Asp. Net Core project templates utilize the Bower package manager for managing client-side package dependencies.
- Bower provides a generic, non-opinionated approach to front-end package management while exposing the package dependency model via an API that a more opinionated build stack may consume. As a result, there are no system-wide dependencies, no common dependencies between apps, and the dependency tree is completely flat. Bower is a package-agnostic version control system that runs on Git. A packed component can be built up of any asset and transported in any manner (e.g., AMD, CommonJS, etc.).
-
Reasons for bower error: command not found.
Bower is reliant on Node.js and the npm package manager. Make sure you have Git installed, as some bower packages require it to be fetched and installed.
I'm assuming you installed Node.js through Homebrew, which annoys users by placing installed npm binaries in a location that isn't generally in their 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.
Although I would prefer to uninstall the Node.js that was installed via Homebrew and install another one via the nodejs.org installer, which does not have this issue.
This issue is not exclusive to Bower and will affect any Node.js binary installed globally, such as grunt, uglify, jshint, etc.
Another reason for this error is probably because you're not adding the npm's binary folder to your system's right Path.
-
How to resolve this issue?
This issue can be resolved by including npm's binary folder in your Path. Here are some useful hints to follow: 1. Look for where your npm global binaries are located: npm config get prefix. This path may be similar to something like this C:\Users\username\AppData\Roaming\npm 2. Add the Path from step one (1) to your Path. Open the Windows Control Panel, type environment into the search box, and then select either Edit account environment variables or Edit 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 be required to restart your command prompt window. You should now be able to enter bower commands.
- For users that are facing issues with the installation in mac, it seems that El Capitan is giving permission issues to install the package in that way:
npm install Bower -g
The solution I've found to avoid the permission errors is using Sudo (superuser do) to grant access for node to download the package like this:
sudo npm install bower -g
Conclusion
As a result, don't think it's Bower when you encounter this kind of error. As mentioned above, sometimes this error is not bower specific; you just need to look into npm global binaries location and fix it, then you're good to go. Happy Troubleshooting :)