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:00

Try changing webpack version to 3.0 and web-dev-server to 2.7.1

Eg:

"devDependencies": {
    "webpack": "^3.0.0",
    "webpack-cli": "2.0.13",
    "webpack-config-utils": "2.0.0",
    "webpack-dev-server": "^2.7.1",
    "webpack-validator": "2.2.7"
}
查看更多
Melony?
3楼-- · 2020-02-03 10:03

Update your Webpack version (and webpack CLI):

npm install --save-dev webpack webpack-cli webpack-dev-server webpack-merge

If you don't use one of those mentioned above, feel free to omit.

查看更多
闹够了就滚
4楼-- · 2020-02-03 10:06

these worked for me:

"webpack": "^4.31.0",
"html-webpack-plugin": "^3.0.0",
"webpack-bundle-analyzer": "^3.3.2",
"webpack-cli": "^3.3.2",
"webpack-dev-server": "^3.3.1",
"webpack-merge": "^4.1.0"
查看更多
三岁会撩人
5楼-- · 2020-02-03 10:07

I forgot to install webpack-cli. So I ran below command and issue got fixed.

npm i -D webpack-cli
查看更多
Ridiculous、
6楼-- · 2020-02-03 10:08

I have used these dependencies Working for me.

"webpack": "^3.0.0",
"webpack-cli": "2.0.13",
"webpack-config-utils": "2.0.0",
"webpack-dev-server": "^2.7.1",
"webpack-validator": "2.2.7"
查看更多
地球回转人心会变
7楼-- · 2020-02-03 10:09

The general situation is due to Webpack and webpack-dev-server version is not compatible. Like I also have this problem, my computer's webpack is 1.15.0, but webpack-dev-server is 2.x above version. So I uninstall webpack-dev-server: npm uninstall webpack-dev-server -g Then install the 1.15.0 version of webpack-dev-server, you can solve this problem by npm install webpack-dev-server@1.15.0 -g

查看更多
登录 后发表回答