Webpack not found, deploying to Heroku Webpack not found, deploying to Heroku express express

Webpack not found, deploying to Heroku


Ok -- this has to do with devDependencies vs. Dependencies in package.jsonAlso, by setting the Heroku config to NPM_CONFIG_PRODUCTION: false I was able to resolve this. Thx internet!


As others have said, Heroku runs node as production NODE_ENV=production, which means your devDependencies don't get installed. Heroku provides node specific build hooks though. I use heroku-prebuild to run npm install --dev, which installs all dependencies and devDependencies.

"scripts": {  ...,  "heroku-prebuild": "npm install --dev",  ...},

Running your app NOT in production mode should probably be avoided. Often developers have "dev mode" specific code that will get filtered out when running in production. Plus if you're doing things a webpack build you definitely want to be in production mode to take advantage of minification, uglifying, etc.

Here's the details from Heroku.

Sometimes, developers need something more production-oriented than the preinstall and postinstall hooks in package.json. For instance, some apps need to set up extra authentication before installing dependencies. Some need to build assets, but not in a development environment. Further examples can be found in the discussion on GitHub.

Node.js developers can now use heroku-prebuild and heroku-postbuild hooks to tailor the build process to their apps.

https://devcenter.heroku.com/changelog-items/844


This happens because heroku by default doesn't install dev Dependencies of package.json, we need to exculsively tell heroku (npm) to install our dev dependencies (webpack is in dev), so running this command should solve the "not found issue"

.

npm install --dev