Cannot find module 'webpack/bin/config-yargs&#

2020-02-03 09:28发布

Getting error when running webpack-dev-server --config config/webpack.dev.js --progress --profile --watch --content-base src/. Here is the error log:

module.js:442
throw err;
^

Error: Cannot find module 'webpack/bin/config-yargs'
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3) 

14条回答
做自己的国王
2楼-- · 2020-02-03 10:25

I've had a similar problem. I think it's related to webpack version. After changing webpack version the latest everything was fine...

查看更多
家丑人穷心不美
3楼-- · 2020-02-03 10:27

I also go this error when I had only installed webpack locally and hadn't installed it globally yet.

I had webpack-dev-server installed globally though and it had a dependency on a global install of webpack. To be fair npm did complain while installing webpack-dev-server:

UNMET PEER DEPENDENCY webpack@^2.2.0

查看更多
登录 后发表回答