I installed bower locally in project, creating a folder 'node_modules' and 'bower' in it. then I run bower on the command line:
$ bower
bower: команда не найдена (command not found)
Why is this? if I install bower globally everything works correctly.
npm install -g bower
The important part is the -g
flag, as that informs npm to install it "globally". This means that npm will create a symlink to the bower binary* in your Node.js binaries folder (which is in your PATH
). This allows your shell (be it Bash, zsh, csh, etc.) to find the command.
npm install bower
?Just running npm install bower
installs the given package into the current folder under node_modules/{package}
. If you do this and try running bower
from the command line, your shell won't know where to find the bower
command because it is not in your PATH
(hence the "command not found" error).
As @Jason noted in the comments, you can explicitly run the bower binary* by running ./node_modules/bower/bin/bower
. When run like this, your shell will know where to find the command. You can, if needed, alias that to something shorter:
alias bower="./node_modules/bower/bin/bower"
* I use the word binary extremely loosely. It's more a file marked as being executable with a shebang atop it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With