Angular 15:错误发生意外错误:“无法找到要链接到 c:path\\node_module 的 webpack-dev-server 副本

DPa*_*tel 5 webpack package.json webpack-dev-server angular-cli angular

Angular 15:错误发生意外错误:“无法找到要在 c:path\node_module 中链接的 webpack-dev-server 副本。我正在尝试使用纱线安装包依赖项,但出现上述错误。该项目前段时间安装和构建得很好,但是,最近它要求使用 webpack-dev-server,而我没有在其他 Angular 项目中明确配置它,想知道它的作用是什么以及为什么它现在问我。提前寻求帮助和意见。

包.json

{
  "name": "@website",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test",
    "lint": "ng lint",
    "lint:staged": "lint-staged",
    "lint:styles": "./node_modules/.bin/stylelint src/**/*.scss --fix",
    "e2e": "ng e2e",
    "cypress:open": "cypress open",
    "cypress:run": "cypress run",
    "cypress:component": "cypress open --component",
    "format": "yarn prettier --write .",
    "prepare": "cd ../.. && husky install src/website-remote-iam/.husky"
  },
  "lint-staged": {
    "*.{js, ts}": [
      "eslint --quiet --fix"
    ],
    "*.{json, md, html, js, ts}": [
      "prettier --write"
    ],
    "*.scss": [
      "stylelint src/**/*.scss"
    ]
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "15.0.2",
    "@angular/common": "15.0.2",
    "@angular/compiler": "15.0.2",
    "@angular/core": "15.0.2",
    "@angular/forms": "15.0.2",
    "@angular/platform-browser": "15.0.2",
    "@angular/platform-browser-dynamic": "15.0.2",
    "@angular/router": "15.0.2",
    "@ngxs/store": "3.7.6",
    "rxjs": "7.6.0",
    "tslib": "2.4.1",
    "zone.js": "0.12.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "15.0.2",
    "@angular-eslint/builder": "15.1.0",
    "@angular-eslint/eslint-plugin": "15.1.0",
    "@angular-eslint/eslint-plugin-template": "15.1.0",
    "@angular-eslint/schematics": "15.1.0",
    "@angular-eslint/template-parser": "15.1.0",
    "@angular/cli": "15.0.2",
    "@angular/compiler-cli": "15.0.2",
    "@cypress/schematic": "2.4.0",
    "@types/jasmine": "4.3.1",
    "@types/node": "18.11.5",
    "@typescript-eslint/eslint-plugin": "5.45.1",
    "@typescript-eslint/parser": "5.45.1",
    "cypress": "11.2.0",
    "eslint": "8.18.0",
    "eslint-config-prettier": "8.5.0",
    "eslint-plugin-cypress": "^2.12.1",
    "eslint-plugin-prettier": "4.2.1",
    "husky": "8.0.2",
    "jasmine-core": "4.5.0",
    "karma": "6.4.0",
    "karma-chrome-launcher": "3.1.0",
    "karma-coverage": "2.2.0",
    "karma-jasmine": "5.1.0",
    "karma-jasmine-html-reporter": "~2.0.0",
    "lint-staged": "13.0.3",
    "ngx-build-plus": "15.0.0",
    "prettier": "2.8.0",
    "prettier-eslint": "15.0.1",
    "pretty-quick": "3.1.3",
    "serverless-localstack": "1.0.0",
    "stylelint": "14.15.0",
    "stylelint-config-prettier-scss": "0.0.1",
    "stylelint-config-standard-scss": "6.1.0",
    "typescript": "4.8.4"
  }
}
Run Code Online (Sandbox Code Playgroud)

安装了 npm install --save-dev webpack-dev-server 还需要安装 npm install --save-dev webpack-dev-middleware webpack-hot-middleware 它绕过了这个错误,但没有构建,说明 cli 版本不匹配