0

I'm trying to build angular application using 'ng build --prod'. Below are the information.

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>

Below are the Angular and Node Version

Angular CLI: 11.2.2
Node: 16.15.1

When I execute 'ng build --prod' it gives me an error

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

I tried installing below. But it also gives error

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

I installed node using by following the below link

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

Container-Man
  • 434
  • 1
  • 6
  • 17

1 Answers1

0

You need update @angular/common from "@angular/common@": "~12.1.1" to "@angular/common@": "^13.0.0" and then run npm i. After that you run ng build to build project and see it builed or not.

Park Numb
  • 521
  • 3
  • 8
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 01 '22 at 05:41