本文介绍了找不到模块“webpack/bin/config-yargs"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行 webpack-dev-server --config config/webpack.dev.js --progress --profile --watch --content-base src/时出错.这是错误日志:

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) 

推荐答案

如果您使用的是 webpack-cli 4 或 webpack 5,请更改 webpack-dev-serverwebpack serve.

If you're using webpack-cli 4 or webpack 5, change webpack-dev-server to webpack serve.

示例:

"serve": "webpack serve --config config/webpack.dev.js --progress"

您可能还想查看此评论GitHub:

You might want also check this comment on GitHub:

NPM package.json 脚本是一种方便且有用的运行方式本地安装的二进制文件而不必担心它们完整路径.简单地定义一个脚本:

对于webpack-cli 3.x:

"scripts": {   "start:dev": "webpack-dev-server" }

对于 webpack-cli 4.x:

"scripts": {   "start:dev": "webpack serve" }

这篇关于找不到模块“webpack/bin/config-yargs"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 04:14