Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 component.json 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 package.json 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.

like image 930
Stefan Avatar asked Feb 06 '13 19:02

Stefan


People also ask

How do you run npm install on Heroku?

Run the npm install command in your local app directory to install the dependencies that you declared in your package. json file. Start your app locally using the heroku local command, which is installed as part of the Heroku CLI. Your app should now be running on http://localhost:5000/.

Does Bower use npm?

Bower is a command line utility. Install it with npm. Bower requires node, npm and git.

What is Bower in npm?

Bower is a package manager, like npm, which manages frameworks, libraries, assets, and utilities, installs them, and makes sure they are up to date. Traditionally, many web development projects combined npm and Bower. npm was used to manage back-end dependencies, while Bower was used for front-end dependencies.


1 Answers

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.

like image 56
xavier.seignard Avatar answered Sep 21 '22 05:09

xavier.seignard