运行 ng serve 时找不到模块“@angular/compiler”

Cannot find module '@angular/compiler' when runnig ng serve

我已经更新了依赖项,从那时起,当 运行 ng serve:

时,我收到了这条错误消息
An unhandled exception occurred: Cannot find module '@angular/compiler'
Require stack:

我已经尝试过以下解决方案: 但对我没有用。 还删除了 node_modules,再次检查该项目。 我的依赖项有问题吗?或者我该怎么做才能再次获得它 运行ning?

这是我的 package.json:

{
"name": "wichteli",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve --host 0.0.0.0 --disable-host-check",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"test:ci": "ng test --browsers ChromeHeadlessCI --code-coverage true --watch false",
"e2e:ci": "ng e2e --protractor-config=e2e/protractor-ci.conf.js",
"e2e": "ng e2e"
 },
 "private": true,
 "devDependencies": {
 "@angular-devkit/build-angular": "~12.0.1",
 "@angular/compiler-cli": "~12.0.1",
 "@types/jasmine": "~3.7.4",
 "@types/node": "^15.6.0",
 "codelyzer": "^6.0.2",
 "jasmine-core": "~3.7.1",
 "jasmine-spec-reporter": "~7.0.0",
 "karma": "~6.3.2",
 "karma-chrome-launcher": "~3.1.0",
 "karma-coverage": "~2.0.3",
 "karma-coverage-istanbul-reporter": "^3.0.3",
 "karma-jasmine": "~4.0.1",
"karma-jasmine-html-reporter": "^1.6.0",
"karma-spec-reporter": "0.0.32",
"protractor": "~7.0.0",
"puppeteer": "^9.1.1",
"ts-node": "~9.1.1",
"tslint": "~6.1.0",
"typescript": "~4.2.4"
}
}

npm 版本输出:

{
  npm: '7.11.2',
  node: '12.18.1',
  v8: '7.8.279.23-node.38',
  uv: '1.38.0',
  zlib: '1.2.11',
  brotli: '1.0.7',
  ares: '1.16.0',
  modules: '72',
  nghttp2: '1.41.0',
  napi: '6',
  llhttp: '2.0.4',
  http_parser: '2.9.3',
  openssl: '1.1.1g',
  cldr: '37.0',
  icu: '67.1',
  tz: '2019c',
  unicode: '13.0'
}

ng --version 输出:

Angular CLI: 12.0.1
Node: 12.18.1
Package Manager: npm 7.11.2
OS: win32 x64

Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1200.1 (cli-only)
@angular-devkit/core         12.0.1 (cli-only)
@angular-devkit/schematics   12.0.1 (cli-only)
@schematics/angular          12.0.1 (cli-only)

我找到了解决办法。 首先,检查如何更新: https://update.angular.io/?l=2&v=12.0-12.0 正在从 12 更新到 13 在此之后, ng serve 或多或少地处理了一些错误消息,这些错误消息表明某些依赖项无法解决,例如 @angular/core

npm install @angular/core

以及所有其他发现

在此之后,一切都恢复正常了