1. 执行npm start,报上面的错误信息,需要安装webpack-dev-server,如果用到webpack-dev-server,同时也需要安装webpack-cli,执行命令如下:
npm install --save-dev webpack-cli
npm install --save-dev webpack-dev-server
2. webpack-dev-server如果是3.x的话,webpack必须是4.x才不会报此TypeError: Cannot read property 'compile' of undefined错误或者Cannot match against 'undefined' or 'null'错误, 同理如果webpack是3.x,则webpack-dev-server必须是2.x。
试着将webpack升为4.x,webpack-dev-server 为2.x。报上面的错误。最终解决方案:webpack为3.x,webpack-dev-server 为2.x,执行如下命令:
npm install --save-dev webpack-dev-server@2