概述
问题:控制台输出, 但页面内容并没有进行热加载
[WDS] App updated. Recompiling...
[WDS] App hot update...
...
报错:
Error: Cannot find module 'webpack-cli/bin/config-yargs'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
at Function.Module._load (internal/modules/cjs/loader.js:506:25)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (E:webpacknode_modules_webpack-dev-server@3.1.14@webpack-dev-serverbinwebpack-dev-server.js:84:1)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! wp@1.0.0 dev: `webpack-dev-server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the wp@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:UsersAdministratorAppDataRoamingnpm-cache_logs2019-02-15T13_59_30_515Z-debug.log
解决:这种情况下一般是webpack版本与webpack-dev-server版本不兼容的问题, 这个时候我们不仅需要检查开发环境所需的webpack版本号与webpack-dev-server号,还要检查生产环境的webpack-dev-server是否一致,不一致则改为一致。
// 查看webpack-dev-server是否一致
"devDependencies": {
...
"webpack": "^3.11.0",
"webpack-dev-server": "^2.11.1",
...
},
"dependencies": {
...
"webpack-dev-server": "^2.11.1",
...
}
到此,可以把项目跑起来,实现热更新。
最后
以上就是兴奋外套为你收集整理的webpack热更新无效解决,页面无刷新的全部内容,希望文章能够帮你解决webpack热更新无效解决,页面无刷新所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复