1. 程式人生 > >webpack4.0 Cannot find module 'webpack/bin/config-yargs'錯誤解決

webpack4.0 Cannot find module 'webpack/bin/config-yargs'錯誤解決

Error: Cannot find module 'webpack/bin/config-yargs'     at Function.Module._resolveFilename (module.js:538:15)     at Function.Module._load (module.js:468:25)     at Module.require (module.js:587:17)     at require (internal/module.js:11:18)     at Object.<anonymous> (C:\Users\hboxs022\Desktop\webpack-demo\webpack-demo\node_modules\webpack-dev-server\bin\webpack-dev-server.js:54:1)     at Module._compile (module.js:643:30)     at Object.Module._extensions..js (module.js:654:10)     at Module.load (module.js:556:32)     at tryModuleLoad (module.js:499:12)     at Function.Module._load (module.js:491:3) error Command failed with exit code 1.

解決辦法:

webpack版本為4.0,已經安裝過webpack-cli.網上找到答案說webpack和webpack-cli要一起安裝,如果已經安裝過webpack,可以使用如下命令重新安裝:

npm add webpack-cli webpack -D

 重新安裝後問題解決.