vue项目初始化时npm run dev报错webpack-dev-server解决方法

vue项目初始化时npm run dev报错webpack-dev-server解决方法

原因:这是新版webpack存在的BUG,卸载现有的新版本webpack,装老版本就好
webpack-dev-server 版本需要从最新版本降低到如下版本,因为开始构建项目所用的插件版本太低
(1)、npm uninstall webpack-dev-server
(2)、npm install webpack-dev-server@2.9.1
(3)、npm run dev
===================
如何执行npm uninstall webpack-dev-server 也报错的话只能用下面方法了
原因是你的node_modules有意外改动,导致依赖库不完整。
解决:
1.删除项目下的node_modules
2.在项目目录下重新执行npm install 或者cnpm install,会重新生成node_modules
3.执行npm run build 或者cnpm run build
4.执行npm run dev 或者cnpm run dev
==================

PS E:\webcode\bigbullmobile> cnpm run dev

> bigbullmobile@1.0.0 dev E:\webcode\bigbullmobile
> webpack-dev-server --inline --progress --config build/webpack.dev.conf.js

internal/modules/cjs/loader.js:573
throw err;
^

Error: Cannot find module 'array-includes'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:571:15)
at Function.Module._load (internal/modules/cjs/loader.js:497:25)
at Module.require (internal/modules/cjs/loader.js:626:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (E:\webcode\bigbullmobile\node_modules\_webpack-dev-server@2.11.3@webpack-dev-server\lib\polyfills.js:6:18)
at Module._compile (internal/modules/cjs/loader.js:678:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:689:10)
at Module.load (internal/modules/cjs/loader.js:589:32)
at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
at Function.Module._load (internal/modules/cjs/loader.js:520:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bigbullmobile@1.0.0 dev: `webpack-dev-server --inline --progress --config build/webpack.dev.conf.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bigbullmobile@1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\zheng\AppData\Roaming\npm-cache\_logs\2019-01-26T18_31_50_813Z-debug.log
PS E:\webcode\bigbullmobile>

 

posted @ 2019-01-27 23:21  大自然的流风  阅读(56498)  评论(3编辑  收藏  举报