react 关于 webpack 打包



 "scripts": {
    "start": "webpack-dev-server --content-base public/",
    "stage": "NODE_ENV=staging webpack -p --config --progress",
    "deploy": "NODE_ENV=production webpack -p --config --progress",
    "debug": "NODE_ENV=debug webpack-dev-server --content-base public/"
  },

正常

npm start

可以跑起来了

可运行

npm run deploy

就报错了


 $ npm run deploy

> [email protected] deploy E:\zan\www\webpack\react-scaffold
> NODE_ENV=production webpack -p --config --progress

'NODE_ENV' ▒▒▒▒▒ڲ▒▒▒▒ⲿ▒▒▒Ҳ▒▒▒ǿ▒▒▒▒еij▒▒▒
▒▒▒▒▒▒▒▒▒ļ▒▒▒

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "D:\\nodejs\\node.exe" "D:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "deploy"
npm ERR! node v4.0.0
npm ERR! npm  v2.14.2
npm ERR! code ELIFECYCLE
npm ERR! [email protected] deploy: `NODE_ENV=production webpack -p --config --progress`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] deploy script 'NODE_ENV=production webpack -p --config --progress'.
npm ERR! This is most likely a problem with the react-scaffold package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     NODE_ENV=production webpack -p --config --progress
npm ERR! You can get their info via:
npm ERR!     npm owner ls react-scaffold
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     E:\zan\www\webpack\react-scaffold\npm-debug.log

而直接运行 webpack -p 正常

哪里写错了吗 求大神指导一下呀

reactjs webpack

蛋疼的路人甲 9 years, 1 month ago

1 . 你得有webpack.production.js文件

2 . 执行webpack --config webpack.production.js

すべてD妄想 answered 9 years, 1 month ago

NODE_ENV=production

是linux设置变量的方法,
windows需要用set

set NODE_ENV=production && webpack -p --config --progress

我系那个啥 answered 9 years, 1 month ago

Your Answer