错误如下:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! webpack5@1.0.0 dev: `webpack-dev-server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the webpack5@1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output ab
ove.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\gyj\AppData\Roaming\npm-cache\_logs\2019-06-04T11_54_18_787Z-debug.log
原因分析:因为webpack-dev-server版本过高。
解决:
删除:node_modules
,
重新安装:npm install
,
安装版本低的webpack-dev-server,如:
npm i webpack-dev-server@2.9.7 -D
如果还有错误,如下:
D:\xampp\htdocs\lianxi\webpack5>npm install webpack-dev-server@2.9.3 -D
npm WARN webpack-dev-server@2.9.3 requires a peer of webpack@^2.2.0 || ^3.0.0 but none is inst
alled. You must install peer dependencies yourself.
npm WARN webpack-dev-middleware@1.12.2 requires a peer of webpack@^1.0.0 || ^2.0.0 || ^3.0.0 b
ut none is installed. You must install peer dependencies yourself.
npm WARN webpack5@1.0.0 No description
npm WARN webpack5@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted
{"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
原因分析:需要本地安装webpack
如:
npm install webpack@3.8.1 -D