Stefan Stefan - 1 year ago 99
Node.js Question

How can I invoke npm on heroku command line (to install bower components)?

Bower is for client side Javascript what npm is for the server side and reads a

file to recognize dependencies that should be fetched at deploy time so I'd be happy it heroku would run it at slug compilation time.

Unfortunately I can not invoke npm or bower from a heroku console or one-off command (
heroku run "npm help"
) (
heroku run bash
npm help
) as it's possible with ruby's rake. I've put npm and node (latest/x versions) in my
but in the engines section, not the dependencies.

I think this could be solved by customizing the node buildpack but I consider this a little too heavy task just for activating something so obvious.

Answer Source

You can also setup a postintall command, something like this in your package.json

"dependencies": {
    "bower": "0.6.x"
"scripts": {
    "postinstall": "./node_modules/bower/bin/bower install"

Then npm install will also install bower dependencies.

Pros : one command to rule them all.

Cons : you unnecessarily embed bower as a dependency.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download