Hashnode / Hashnode/mern-starter

Error: Cannot find module 'webpack' on production environment

Open
#254 1 comment 0 reactions 0 assignees View on GitHub
discussion V2.6.0
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
![screenshot from 2016-10-25 09-17-24](https://cloud.githubusercontent.com/assets/43447/19670738/eaaa9c08-9a93-11e6-80c3-4b973c3883e3.png)

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.