angularjs NG生成命令失败

rhfm7lfc  于 2022-10-31  发布在  Angular
关注(0)|答案(1)|浏览(177)

我正在尝试使用“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 和节点版本

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

flvlnr44

flvlnr441#

您需要从“@angular/common@"更新@angular/common @:将“~12.1.1”更改为“Angular /公共":“^13.0.0”,然后运行npm i。然后运行ng build来构建项目,并查看是否已构建。

相关问题