react-router-tutorial icon indicating copy to clipboard operation
react-router-tutorial copied to clipboard

webpack installed only in devDependencies but used in production

Open scott4dev opened this issue 9 years ago • 1 comments

Hi,

First I want to thank you very much for this awesome tutoral. The quality of this material is great!

I've noticed that in the lesson 12-navigating the package.json file use the npm start command in this way

 "scripts": {
     "start": "if-env NODE_ENV=production && npm run start:prod || npm run start:dev",
     "start:dev": "webpack-dev-server --inline --content-base public/ --history-api-fallback",
     "start:prod": "webpack && node server.js"
},

if you run it in development mode it works like a charm but if you start from scratch and you'll do

npm install --production
NODE_ENV=production npm start

you'll get this error

> [email protected] start /Users/..../dev/garbage/react-router-tutorial/lessons/12-navigating
> if-env NODE_ENV=production && npm run start:prod || npm run start:dev


> [email protected] start:prod /Users/..../dev/garbage/react-router-tutorial/lessons/12-navigating
> webpack && node server.js

sh: webpack: command not found

as you can see from the copied package.json here below webpack is installed only in development mode

{
  "name": "tutorial",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "if-env NODE_ENV=production && npm run start:prod || npm run start:dev",
    "start:dev": "webpack-dev-server --inline --content-base public/ --history-api-fallback",
    "start:prod": "webpack && node server.js"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "compression": "^1.6.1",
    "if-env": "^1.0.0",
    "react": "^0.14.7",
    "react-dom": "^0.14.7",
    "react-router": "^2.0.0"
  },
  "devDependencies": {
    "babel-core": "^6.5.1",
    "babel-loader": "^6.2.2",
    "babel-preset-es2015": "^6.5.0",
    "babel-preset-react": "^6.5.0",
    "http-server": "^0.8.5",
    "webpack": "^1.12.13",
    "webpack-dev-server": "^1.14.1"
  }
}

I've discovered this issue publishing an app based on the package.json to heroku. Maybe a solution like this can help you

scott4dev avatar Apr 17 '16 09:04 scott4dev

Yes, we should probably have a separate build step there. Can you submit a PR to fix this?

timdorr avatar Apr 28 '16 14:04 timdorr