简体   繁体   English

运行 webpack-dev-server 时找不到模块“webpack-cli/bin/config-yargs”

[英]Cannot find module 'webpack-cli/bin/config-yargs' when running webpack-dev-server

I'm getting this error when running the command below in order to run webpack dev server.运行以下命令以运行 webpack 开发服务器时出现此错误。 While checking in some pages, most people mention it may be related to webpack outdated versions, but I believe my components are all on the most current version:在查看某些页面时,大多数人提到它可能与 webpack 过时版本有关,但我相信我的组件都在最新版本上:

  • webpack-dev-server@3.11.2 webpack-dev-server@3.11.2
  • webpack-cli@4.5.0 webpack-cli@4.5.0
  • webpack@5.24.4 webpack@5.24.4

This is the command I'm running to start the webpack dev server:这是我正在运行以启动 webpack 开发服务器的命令:

npx webpack-dev-server --compress --history-api-fallback --progress --host 0.0.0.0 --port 3005

This is my Package.json:这是我的 Package.json:

{
  "name": "rcweb",
  "version": "1.0.0",
  "description": "rcweb",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "watch": "webpack-dev-server --compress --history-api-fallback --progress --host 0.0.0.0 --port 3005"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@types/react": "^17.0.3",
    "@types/react-dom": "^17.0.2",
    "@types/react-redux": "^7.1.16",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-redux": "^7.2.2",
    "redux": "^4.0.5",
    "ts-loader": "^8.0.17",
    "typescript": "^4.2.3",
    "webpack": "^5.24.4",
    "webpack-cli": "^4.5.0",
    "webpack-dev-server": "^3.11.2"
  },
  "dependencies": {}
}

This is the error Output:这是错误 Output:

Cannot find module 'webpack-cli/bin/config-yargs'
Require stack:
- /home/user/dev/tests/reduxchat/rcweb/node_modules/webpack-dev-server/bin/webpack-dev-server.js

I still don't know the reason for this error, but worked around it by running webpack serve .我仍然不知道这个错误的原因,但通过运行webpack serve解决了这个问题。 Worked fine.工作得很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM