xetra11 xetra11 - 1 month ago 6
Node.js Question

Executing local (--save-dev) tools by npm

I just installed bower via

npm install bower --save-dev
because I want to have this available for everybody who checks the branch out and runs "npm update". I knew how to execute bower if I installed it with
npm install bower -g
but how do I actually execute it now?

this way does not satisfy me:

./node_modules/bower/bin/bower -v


Isn't there something like
npm tools bower -v
?

Answer

No, there is no npm tools command. But here is an alternative solution.

If your shell is bash, you can add function into your .bashrc.

# ~/.bashrc
function npm-tools {                                                                                                  
    (PATH=$(npm bin):$PATH; eval $@;)                                                                              
}

Then you can run command like following to achieve what you want.

# $ tree node_modules/ -L=1
# node_modules/
# └── bower
$ ./node_modules/bower/bin/bower -v
1.7.9
$ npm-tools bower -v
1.7.9