How do you use Node.js devDependencies in the App Platform builds? Heroku automatically installs both the dependencies and devDependencies for the app build and then removes the devDependencies after the build is complete. This ensures that you’re only including the minimum required dependencies in production.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
4 answers

👋 @Rowno

Including dev dependencies is a good idea and I’ve created a ticket with the team to include this and clear out the dev deps after build to only include necessary deps for production.

For now a workaround is to customize your build command to something like:

npm install --only=dev && npm run build && npm prune --production

This will install the devDependencies (dependencies have already been installed) then run the build, finally will remove the devDependencies.

I was able to resolve the issue by using npm install --production=false, then build.