Hashnode / Hashnode/mern-starter
Error: Cannot find module 'webpack' on production environment
- Dominant language
- JavaScript
- Stars
- 5.1k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
Why is it webpack needed for production environment even after I build for production? Steps to reproduce:
1. mern init foo
2. cd foo
3. npm install
4. npm start // => runs OK
5. npm run build
6. npm run build:server
7. rm -rf node_modules
8. npm install --production
9. npm run start:prod
10. error

I believe those are the steps to deploy in production mode and npm install --production is what we should do, but that render the app unusable. If that's not the case then webpack and its plugins should be in `dependencies` and not in `devDependencies` in `package.json`.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by inspecting package.json, especially the npm scripts and dependency sections, then reproduce the listed production-install and start commands. Done means the production startup no longer fails to find webpack, or the package configuration and deployment expectation are clearly corrected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js, webpack
- Domain
- build-system, devops
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100