升级后的 Angular 16 应用程序正在生成错误

问题描述 投票:0回答:1

我有一个 Angular 10 应用程序,我尝试更新并使其使用 Angular 16。我按照 Angular 更新指南 页面升级,一次一个版本。一切都很顺利,直到我尝试从 Angular 15 迁移到 Angular 16。现在,当我在 Visual Studio Code 终端中执行“ng version”命令时,我看到了以下内容:

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>

为什么列出这么多错误?

“ng build”命令会生成此快速错误:

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

运行“npm install”会在执行该过程一段时间后生成此错误:

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: [email protected]
npm ERR! Found: @angular-devkit/[email protected]
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/[email protected]
npm ERR! node_modules/@angular/compiler-cli
npm ERR!   peer @angular/compiler-cli@"^16.0.0" from @angular-devkit/[email protected]     
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

有什么想法吗? 埃德

node.js angular npm npm-install
1个回答
0
投票

从您的 npm 错误中可以看出,您似乎与仍处于版本 15 的 angular-devkit/build-angular 的安装版本存在差异。

我建议运行以下命令

ng update @angular-devkit/build-angular@16

然后检查是否有更多错误。

© www.soinside.com 2019 - 2024. All rights reserved.