Upgraded Angular 16 application is generating errors

Discussão em 'Angular' iniciado por Eddie, Fevereiro 17, 2025.

  1. Eddie

    Eddie Guest

    I have an Angular 10 application that I tried to update and make it use Angular 16. I followed the Angular Update Guide page and went up, one version at a time. It all went smooth until I tried moving from Angular 15 to Angular 16. Now, when I execute the "ng version" command in my Visual Studio Code terminal, I see this:

    Angular CLI: 16.2.14
    Node: 16.20.2
    Package Manager: npm 8.19.4
    OS: win32 x64

    Angular: <error>
    ... animations, cdk, common, compiler, compiler-cli, core, forms
    ... platform-browser, platform-browser-dynamic, router

    Package Version
    ---------------------------------------------------------
    @angular-devkit/architect 0.1602.14 (cli-only)
    @angular-devkit/build-angular <error>
    @angular-devkit/core 16.2.14 (cli-only)
    @angular-devkit/schematics 16.2.14 (cli-only)
    @angular/cli 16.2.14 (cli-only)
    @schematics/angular 16.2.14 (cli-only)
    rxjs 7.8.1 (cli-only)
    typescript <error>
    zone.js <error>


    Why are there so many errors listed?

    The "ng build" command generates this quick error:

    Error: Could not find the '@angular-devkit/build-angular:browser' builder's node package.


    Running "npm install" generates this error, after it goes through the process for a while:

    npm ERR! code 1
    npm ERR! path C:\Projects\DevSystems\MMWA\Source\UI\TabletApp\tablet-app\node_modules\esbuild
    npm ERR! command failed
    npm ERR! command C:\windows\system32\cmd.exe /d /s /c node install.js
    npm ERR! node:internal/errors:857
    npm ERR! const err = new Error(message);
    npm ERR! ^
    npm ERR!
    npm ERR! Error: Command failed: C:\Program Files\nodejs\node.exe C:\Projects\DevSystems\MMWA\Source\UI\TabletApp\tablet-app\node_modules\esbuild\bin\esbuild --version
    npm ERR! node:child_process:899
    npm ERR! throw err;
    npm ERR! ^
    npm ERR!
    npm ERR! <ref *1> Error: spawnSync C:\Projects\DevSystems\MMWA\Source\UI\TabletApp\tablet-app\node_modules\@esbuild\win32-x64\esbuild.exe UNKNOWN
    npm ERR! at Object.spawnSync (node:internal/child_process:1119:20)
    npm ERR! at spawnSync (node:child_process:847:24)
    npm ERR! at Object.execFileSync (node:child_process:890:15)
    npm ERR! at Object.<anonymous> (C:\Projects\DevSystems\MMWA\Source\UI\TabletApp\tablet-app\node_modules\esbuild\bin\esbuild:220:28)
    npm ERR! at Module._compile (node:internal/modules/cjs/loader:1198:14)
    npm ERR! at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
    npm ERR! at Module.load (node:internal/modules/cjs/loader:1076:32)
    npm ERR! at Function.Module._load (node:internal/modules/cjs/loader:911:12)
    npm ERR! at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    npm ERR! at node:internal/main/run_main_module:22:47 {
    npm ERR! errno: -4094,
    npm ERR! code: 'UNKNOWN',
    npm ERR! syscall: 'spawnSync C:\\Projects\\DevSystems\\MMWA\\Source\\UI\\TabletApp\\tablet-app\\node_modules\\@esbuild\\win32-x64\\esbuild.exe',
    npm ERR! path: 'C:\\Projects\\DevSystems\\MMWA\\Source\\UI\\TabletApp\\tablet-app\\node_modules\\@esbuild\\win32-x64\\esbuild.exe',
    npm ERR! spawnargs: [ '--version' ],
    npm ERR! error: [Circular *1],
    npm ERR! status: null,
    npm ERR! signal: null,
    npm ERR! output: null,
    npm ERR! pid: 0,
    npm ERR! stdout: null,
    npm ERR! stderr: null
    npm ERR! }
    npm ERR!
    npm ERR! at checkExecSyncError (node:child_process:861:11)
    npm ERR! at Object.execFileSync (node:child_process:896:15)
    npm ERR! at validateBinaryVersion (C:\Projects\DevSystems\MMWA\Source\UI\TabletApp\tablet-app\node_modules\esbuild\install.js:98:28)
    npm ERR! at C:\Projects\DevSystems\MMWA\Source\UI\TabletApp\tablet-app\node_modules\esbuild\install.js:283:5 {
    npm ERR! status: 1,
    npm ERR! signal: null,
    npm ERR! output: [
    npm ERR! null,
    npm ERR! Buffer(0) [Uint8Array] [],
    npm ERR! Buffer(1377) [Uint8Array] [
    npm ERR! 110, 111, 100, 101, 58, 99, 104, 105, 108, 100, 95, 112,
    npm ERR! 114, 111, 99, 101, 115, 115, 58, 56, 57, 57, 13, 10,
    npm ERR! 32, 32, 32, 32, 116, 104, 114, 111, 119, 32, 101, 114,
    npm ERR! 10, 60, 114, 101, 102, 32, 42, 49, 62, 32, 69, 114,
    PS C:\Projects\DevSystems\MMWA\Source\UI\TabletApp\tablet-app> npm install
    npm ERR! code ERESOLVE
    npm ERR! ERESOLVE could not resolve
    npm ERR!
    npm ERR! While resolving: panynj-tablet-app@0.0.0
    npm ERR! Found: @angular-devkit/build-angular@15.2.11
    npm ERR! node_modules/@angular-devkit/build-angular
    npm ERR! dev @angular-devkit/build-angular@"^16.2.14" from the root project
    npm ERR!
    npm ERR! Could not resolve dependency:
    npm ERR! dev @angular-devkit/build-angular@"^16.2.14" from the root project
    npm ERR!
    npm ERR! Conflicting peer dependency: @angular/compiler-cli@16.2.12
    npm ERR! node_modules/@angular/compiler-cli
    npm ERR! peer @angular/compiler-cli@"^16.0.0" from @angular-devkit/build-angular@16.2.14
    npm ERR! node_modules/@angular-devkit/build-angular
    npm ERR! dev @angular-devkit/build-angular@"^16.2.14" from the root project
    npm ERR!
    npm ERR! Fix the upstream dependency conflict, or retry
    npm ERR! this command with --force, or --legacy-peer-deps
    npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
    npm ERR!
    npm ERR! See C:\Users\el\AppData\Local\npm-cache\eresolve-report.txt for a full report.

    npm ERR! A complete log of this run can be found in:
    npm ERR! C:\Users\el\AppData\Local\npm-cache\_logs\2024-05-01T00_37_05_023Z-debug-0.log


    Any thoughts? Ed

    Edit: I'll use edits to post comments and address some of the suggestions you have made. For Tibere, issueing that command gives this error:

    Using package manager: npm
    Collecting installed dependencies...
    Found 0 dependencies.
    Package '@angular-devkit/build-angular' is not a dependency.


    For Yassin, I removed the contents of the node_modules folder and issued the 'npm install' command. It generates an error that has been shown above:

    npm ERR! code ERESOLVE
    npm ERR! ERESOLVE could not resolve
    npm ERR!
    npm ERR! While resolving: panynj-tablet-app@0.0.0
    npm ERR! Found: @angular-devkit/build-angular@15.2.11
    npm ERR! node_modules/@angular-devkit/build-angular
    npm ERR! dev @angular-devkit/build-angular@"^16.2.14" from the root project
    npm ERR!
    npm ERR! Could not resolve dependency:
    npm ERR! dev @angular-devkit/build-angular@"^16.2.14" from the root project
    npm ERR!
    npm ERR! Conflicting peer dependency: @angular/compiler-cli@16.2.12
    npm ERR! node_modules/@angular/compiler-cli
    npm ERR! peer @angular/compiler-cli@"^16.0.0" from @angular-devkit/build-angular@16.2.14
    npm ERR! node_modules/@angular-devkit/build-angular
    npm ERR! dev @angular-devkit/build-angular@"^16.2.14" from the root project
    npm ERR!
    npm ERR! Fix the upstream dependency conflict, or retry
    npm ERR! this command with --force, or --legacy-peer-deps
    npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
    npm ERR!
    npm ERR! See C:\Users\elascu\AppData\Local\npm-cache\eresolve-report.txt for a full report.

    npm ERR! A complete log of this run can be found in:
    npm ERR! C:\Users\el\AppData\Local\npm-cache\_logs\2024-05-01T14_44_39_506Z-debug-0.log


    I do have angular-devkit listed as a dependency:

    "devDependencies": {
    "@angular-devkit/build-angular": "^16.2.14",


    Problem may arise from the fact that in the package-lock.json file I have the old one that did not get migrated:

    "devDependencies": {
    "@angular-devkit/build-angular": "^15.2.11",


    I also cleaned the npm cache several times, but that did not help.

    Continue reading...

Compartilhe esta Página