Error: Cannot find module 'webpack' when deploying to heroku
Move webpack (and any other tools you rely on for building your Heroku slug from "devDependencies" to "dependencies" in your package.json.
You should also be able to call it with just plain "webpack" instead of ./node_modules/.bin/webpack.
By default, "devDependencies" only get installed in node_modules on Dev platforms, whereas Heroku is defined as a production platform.
Heroku error: Cannot find module webpack
This is more of a trouble shoot answer, but this issue generally arises with one of two issues:
- webpack is globally installed (at some point you did
npm install webpack -g
) - webpack is installed as a devDependency.
If you are running a server that require's in webpack
, you're going to install it as a dependency
.
If you're not doing any serverside middleware, then setting webpack
as a devDependency is generally what you want.
When trying to push application to Heroku, I receive a Webpack error about version 5
So i found the solution to my own problem. I changed 'react-scripts' from version 5.0.1 to version 4.0.3, then I did a npm install
to change anything due to this version change and it worked! I did this step previously but it did not work but this time I did a npm install
after version change which fixed it.
Error in deploying on heroku, /bin/sh: 1: webpack: not found
Try this:
heroku config:set NPM_CONFIG_PRODUCTION=false
Then, in your package.json, replace the "postinstall" you have under "scripts" with this:
"heroku-postbuild": "webpack --config webpack.prod.js",
For other options, see Hosting a production React app built with Wepback on Heroku.
Related Topics
Selenium Webdriver Take Screenshot of Viewport Only
Rails - How to Add Contacts to Sendgrid Marketing Campaigns via API
Sorting of 2D Array by Its Amount of in the Inner Elements
Devise 'Find_First_By_Auth_Conditions' Method Explanation
Deleting a Line in a Text File
I Want to Match All Punctuation in My Regexp Except Apostrophes. How to Do That in Ruby
How to Check If a Specific Key Is Present in a Hash or Not
Difference Between Block and &Block in Ruby
Connection Refused Using Sunspot and Solr in Rails
Webpack Error on Heroku Deployment
Ruby on Rails - Error Making New App (Rb:55:In 'Require')
How to Use Link_To with Ajax in Rails 3.2.1
Setting a Text Field That Has a Jquery Mask on It