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).
npm install
option. It always runsnpm install --production
followed bynpm rebuild
. It is possible, however, to create your own buildpack on heroku that specifies a different behavior fornpm install
.