node.jsangularangular-cling-build

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


I've updated the dependencies and since then, I've got this error message when run ng serve:

An unhandled exception occurred: Cannot find module '@angular/compiler'
Require stack:

I've tried already this solutions: Cannot find module '@angular/compiler' But didn't work for me. Also deleted node_modules, checkout the project again. Is there something wrong in my dependencies or what can I do to get it running again?

This is my 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 version output:

{
  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 output:

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)

Solution

  • I've found a solution. First, check how to update: https://update.angular.io/?l=2&v=12.0-12.0 Was updating from 12 to 13 After this, ng serve worked more or less with a few error messages that some dependencies couldn't be resolved like @angular/core

    npm install @angular/core
    

    and for all other findings

    after this, all was working again