Webpack-dev-server配置 :执行npm run dev:client时报cli错误,安装了cli解决了问题后又报错:compile 找不到,这要怎么处理

来源:2-6 Webpack-dev-server配置

慕莱坞4101375

2018-03-29

\react+webpack\node_modules\webpack-dev-server\bin\webpack-dev-server.js:405
    throw e;
    ^

TypeError: Cannot read property 'compile' of undefined

npm ERR! Windows_NT 10.0.16299
npm ERR! argv "D:\\Program Files\\nodejs\\node.exe" "D:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev:client"
npm ERR! node v6.13.1
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! react-webpack@1.0.0 dev:client: `cross-env NODE_ENV=development webpack-dev-server --config build/webpack.config.client.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-webpack@1.0.0 dev:client script 'cross-env NODE_ENV=development webpack-dev-server --config build/webpack.config.client.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the react-webpack package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     cross-env NODE_ENV=development webpack-dev-server --config build/webpack.config.client.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs react-webpack
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls react-webpack
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:

其中我的package.json的配置如下:

  "devDependencies": {
    "babel-core": "^6.26.0",
    "babel-loader": "^7.1.4",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-es2015-loose": "^8.0.0",
    "babel-preset-react": "^6.24.1",
    "cross-env": "^5.1.4",
    "html-webpack-plugin": "^3.1.0",
    "webpack": "^3.11.0",
    "webpack-dev-server": "^3.1.1"
  },
  "dependencies": {
    "react-dom": "^16.2.0"
  }

写回答

3回答

慕标6347362

2018-05-07

webpack工具更新速度非常快,最好的跟着课程的版本走。

0
0

慕莱坞4101375

提问者

2018-03-30

看了这么多的问题,总结一条:几乎都是版本问题,版本不对应

0
0

慕莱坞4101375

提问者

2018-03-29

经历了多次尝试,最终将webpack删除,按照报错提示重新安装了指定版本:

npm install webpack@4.0.0-beta.1 终于可以了


0
1
慕慕026387
你用4.0版本的时候,运行起来之后控制台有没有出现很多警告信息?
2018-04-18
共1条回复

React全栈+服务器渲染(ssr)打造社区Webapp

【毕设面试】只会写业务代码?out了,带你学会搭建属于自己的工程!

768 学习 · 414 问题

查看课程