ShakaCode | ShakaCode Blog | Rails On Maui Blog | Rails | ReactJs | JavaScript | Webpack | Productivity |

Notes on Deploying to Heroku with GSL and Node


I ran into a problem where Heroku would not install node dependencies specified in package.json. Specifically, I was getting the message:

Running: rake assets:precompile
cd webpack && $(npm bin)/webpack --config webpack.rails.config.js
sh: /tmp/build_bf971752-54a9-4b3e-9b22-b6f1f7f8f5e7/node_modules/.bin/webpack: not found
rake aborted!
Command failed with status (127): [cd webpack && $(npm bin)/webpack --config …]

(more about the issue here)

I have a project that depends on Node and GSL.

This is handled by the contents of file: /.buildpacks, which contains:

It’s critical to use this buildpack loader allows env variables to go from one buildpack to the next:

You have to set this with:

heroku config:set BUILDPACK_URL=""

I had problems with the Heroku deploy caching, so I had to run these commands to clear the cache:

   heroku plugins:install
   heroku repo:purge_cache -a <my-app>

Note, when updating package.json, it’s critical to run


and to then commit npm-shrinkwrap.json

Or else Heroku won’t update the npm packages!




Thanks for taking this on, Justin.

I ran the following:

heroku config:set BUILDPACK_URL=""
heroku plugins:install
heroku repo:purge_cache -a <director name>

However, I still get the error in your OP. Adding GSL did not help. Can you think of anything else I should try or should I bring this up with Heroku?


@jkbrooks, are you using GSL? If not, you definitely don’t want it. The multi-buildpack should work great.


I am not using GSL. I sent Heroku an email yesterday and will update this forum on what they say.


From Heroku:

That project builds assets remotely on a production server, so webpack needs to be moved from devDependencies to dependencies. DevDependencies are only used locally (on the developer’s machine), and are not executed when you run npm install --production (which is run by Heroku’s node buildpack). So with a default configuration, devDependencies won’t be installed on a production server at all.

Also, it looks like the project is using npm’s shrinkwrap. Npm isn’t great at keeping package.json and npm-shrinkwrap.json in sync, so currently we Node devs have to do that manually with something like this:
rm npm-shrinkwrap.json; npm install; npm shrinkwrap

tl;dr: In package.json, I moved of the devDependencies node modules to dependencies and I now run rm npm-shrinkwrap.json; npm install; npm shrinkwrap before pushing to Heroku and everything works now.


Hi @jkbrooks, yes, that’s correct. I should have updated the article to reflect that. I ran into that same issue. Your statements are spot on. Thanks!


@jkbrooks I’m curious if you ever do a rm node_modules before doing the npm install?


@justin I haven’t needed to, have you?


Well, I was overdoing it until I saw your note, and that seem sufficient. Seems that npm shrinkwrap should have an option so you don’t have to manually rm it.