webpack Error: Cannot find module 'webpack-cli/bin/config-yargs'

电脑使用的webpack版本为3.12.0

局部安装webpack-dev-server,并且全局安装webpack-dev-server后,发现如下error

webpack-dev-server
The CLI moved into a separate package: webpack-cli
Please install 'webpack-cli' in addition to webpack itself to use the CLI
-> When using npm: npm i -D webpack-cli
-> When using yarn: yarn add -D webpack-cli
module.js:549
    throw err;
    ^

Error: Cannot find module 'webpack-cli/bin/config-yargs'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object. (/Users/zhq.yin/Documents/ProjectBuild/webpack_test/node_modules/webpack-dev-server/bin/webpack-dev-server.js:84:1)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)

查看资料

https://blog.csdn.net/longzhoufeng/article/details/81026467

后,发现webpack3.x的版本与webpack-dev-server3.x不兼容

卸载局部和全局webpack-dev-server

npm uninstall -g webpack-dev-server

 npm uninstall --save-dev webpack-dev-server

 

 

安装指定版本的webpack-dev-server2.9.7

npm install [email protected] --save-dev

-bash: /usr/local/bin/webpack-dev-server: No such file or directory

全局安装webpack-dev-server2.9.7

npm install [email protected] -g

后可以实现热加载。

你可能感兴趣的:(webpack Error: Cannot find module 'webpack-cli/bin/config-yargs')