NG构建命令失败



我正在尝试使用'ng build -prod'构建angular应用程序。以下是相关信息。

ng v
_                      _                 ____ _     ___
/    _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
/ △  | '_  / _` | | | | |/ _` | '__|   | |   | |    | |
/ ___ | | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   __| |_|__, |__,_|_|__,_|_|       ____|_____|___|
|___/

Angular CLI: 11.2.2
Node: 16.15.1
OS: linux x64
Angular: <error>
... animations, common, compiler, compiler-cli, core, fire
... forms, platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes
Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1102.2 (cli-only)
@angular-devkit/build-angular   <error>
@angular-devkit/core            11.2.2 (cli-only)
@angular-devkit/schematics      11.2.2 (cli-only)
@angular/cli                    11.2.2 (cli-only)
@schematics/angular             11.2.2 (cli-only)
@schematics/update              0.1102.2 (cli-only)
rxjs                            6.6.3 (cli-only)
typescript                      <error>

下面是Angular和Node版本

Angular CLI: 11.2.2
Node: 16.15.1

当我执行'ng build——prod'时,它给了我一个错误

ng build --prod
An unhandled exception occurred: Cannot find module '@angular-devkit/build-angular/package.json'
Require stack:
- /usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/architect/node/node-modules-architect-host.js
- /usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/architect/node/index.js
- /usr/local/lib/node_modules/@angular/cli/models/architect-command.js
- /usr/local/lib/node_modules/@angular/cli/commands/build-impl.js
- /usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tools/export-ref.js
- /usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tools/index.js
- /usr/local/lib/node_modules/@angular/cli/utilities/json-schema.js
- /usr/local/lib/node_modules/@angular/cli/models/command-runner.js
- /usr/local/lib/node_modules/@angular/cli/lib/cli/index.js
- /usr/local/lib/node_modules/@angular/cli/lib/init.js
- /usr/local/lib/node_modules/@angular/cli/bin/ng
See "/tmp/ng-SgEf1b/angular-errors.log" for further details

我尝试在下面安装。但它也给出了错误

npm install @angular-devkit/build-angular
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: xxxxx-admin@0.0.0
npm ERR! Found: @angular/common@12.1.5
npm ERR! node_modules/@angular/common
npm ERR!   @angular/common@"~12.1.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"^13.0.0" from ngx-webstorage@9.0.0
npm ERR! node_modules/ngx-webstorage
npm ERR!   ngx-webstorage@"^9.0.0" 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 /home/ubuntu/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ubuntu/.npm/_logs/2022-06-09T14_10_24_258Z-debug-0.log

我安装节点使用下面的链接

https://github.com/nodesource/distributions/blob/master/README.md

你需要从"@angular/common@": "~12.1.1"@angular/common@": "^13.0.0"然后运行NPM i。然后运行ng build来构建项目,看看它是否被构建了。

最新更新