Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Skip "Installing dependencies with npm" step when pushing a Node.js app to Heroku

Running git push heroku master always triggers a step that prompts:

Installing dependencies with npm

This step loads and reinstalls all of the dependencies again even it already exists. This is very time consuming and I want to skip this step sometimes when I deploy that I know the dependencies are the same.

Is there any command or options that do this?

like image 208
Hlung Avatar asked Oct 15 '12 09:10

Hlung


1 Answers

Its been a long time since you asked this question, now the Heroku buildpack caches node_modules, so install times will be much faster.

If however you still want to block npm install, here is one solution.

As of when I write this, the default Heroku build pack does not allow skipping npm install entirely. You can see in the dependencies.sh file, this line will always run:

npm install --unsafe-perm --userconfig $build_dir/.npmrc 2>&1

However, if you create a file called .npmrc in your project folder with the following contents:

dry-run

This will cause npm install to not modify your existing node_modules directory.

Note that this change will also apply to the npm prune command that Heroku runs, but WILL NOT apply to the npm rebuild command (which is probably fine).

like image 118
JBCP Avatar answered Oct 29 '22 03:10

JBCP