Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency error when updating from v11 to v12 using "ng update" with v12 cli. #21204

Closed
1 of 15 tasks
jdussouillez opened this issue Jun 25, 2021 · 3 comments
Closed
1 of 15 tasks
Labels
npm 7 npm 7 related issue

Comments

@jdussouillez
Copy link

jdussouillez commented Jun 25, 2021

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • extract-i18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Well this is the first time I get an error using ng update so it worked fine before the v12.

Description

I'm getting an error on dependencies when updating an Angular app from v11 to v12 using ng update.

🔬 Minimal Reproduction

  • Create a v11 app
  • Update it to 12.1.0 using ng update
npx -p @angular/cli@11.2.14 ng new testapp \
    --routing true \
    --style scss \
    --strict true \
    --package-manager npm \
    && cd testapp \
    && ng update @angular/core@12.1.0 @angular/cli@12.1.0

🔥 Exception or Error


```
[...]
CREATE testapp/e2e/src/app.po.ts (274 bytes)
✔ Packages installed successfully.
    Successfully initialized git.
Using package manager: 'npm'
Collecting installed dependencies...
Found 28 dependencies.
Fetching dependency metadata from registry...
    Updating package.json with dependency @angular-devkit/build-angular @ "12.1.0" (was "0.1102.14")...
    Updating package.json with dependency @angular/cli @ "12.1.0" (was "11.2.14")...
    Updating package.json with dependency @angular/compiler-cli @ "12.1.0" (was "11.2.14")...
    Updating package.json with dependency karma @ "6.3.4" (was "6.1.2")...
    Updating package.json with dependency typescript @ "4.3.4" (was "4.1.6")...
    Updating package.json with dependency @angular/animations @ "12.1.0" (was "11.2.14")...
    Updating package.json with dependency @angular/common @ "12.1.0" (was "11.2.14")...
    Updating package.json with dependency @angular/compiler @ "12.1.0" (was "11.2.14")...
    Updating package.json with dependency @angular/core @ "12.1.0" (was "11.2.14")...
    Updating package.json with dependency @angular/forms @ "12.1.0" (was "11.2.14")...
    Updating package.json with dependency @angular/platform-browser @ "12.1.0" (was "11.2.14")...
    Updating package.json with dependency @angular/platform-browser-dynamic @ "12.1.0" (was "11.2.14")...
    Updating package.json with dependency @angular/router @ "12.1.0" (was "11.2.14")...
  UPDATE package.json (1194 bytes)
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! Found: @angular-devkit/build-angular@0.1102.14
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR!   dev @angular-devkit/build-angular@"~12.1.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! dev @angular-devkit/build-angular@"~12.1.0" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: @angular/compiler-cli@12.1.0
npm ERR! node_modules/@angular/compiler-cli
npm ERR!   peer @angular/compiler-cli@"^12.0.0 || ^12.1.0-next" from @angular-devkit/build-angular@12.1.0
npm ERR!   node_modules/@angular-devkit/build-angular
npm ERR!     dev @angular-devkit/build-angular@"~12.1.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/junior/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/junior/.npm/_logs/2021-06-25T12_34_42_916Z-debug.log
✖ Package install failed, see above.
```

🌍 Your Environment

My env (updated to v12.1.0 this morning). It seems to be the same problem : a dependency error with some packages.


Angular CLI: 12.1.0
Node: 14.16.1
Package Manager: npm 7.19.0
OS: linux x64

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

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1201.0 (cli-only)
@angular-devkit/build-angular   <error>
@angular-devkit/core            12.1.0 (cli-only)
@angular-devkit/schematics      12.1.0 (cli-only)
@angular/cli                    12.1.0 (cli-only)
@schematics/angular             12.1.0 (cli-only)
rxjs                            6.6.7 (cli-only)
typescript                      <error>

A co-worker's env - He has the same error


Angular CLI: 12.1.0
Node: 14.16.1
Package Manager: npm 7.19.0
OS: linux x64
Angular: 
... 
Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1201.0 (cli-only)
@angular-devkit/core         12.1.0 (cli-only)
@angular-devkit/schematics   12.1.0 (cli-only)
@schematics/angular          12.1.0 (cli-only)

Another coworker's env - it works fine, no error


Angular CLI: 11.2.2
Node: 14.17.1
OS: win32 x64
Angular: 11.2.2
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, language-service, localize, material
... platform-browser, platform-browser-dynamic, router
... service-worker
Ivy Workspace: Yes
Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1102.2
@angular-devkit/build-angular   0.1102.2
@angular-devkit/core            11.2.2
@angular-devkit/schematics      11.2.2
@angular/pwa                    0.1102.2
@schematics/angular             11.2.2
@schematics/update              0.1102.2
rxjs                            6.6.3
typescript                      4.1.5

It works for him, I guess because it's still using the v11 cli
I tried again after I downgraded my global cli to v11.2.2 (npm i -g @angular/cli@11.2.2) but I still got the same error.

I also upgraded my node to v14.17.1, but same error.

@clydin
Copy link
Member

clydin commented Jun 25, 2021

The dependency @angular/compiler-cli@12.1.0 satisfies the SemVer dependency range of @angular/compiler-cli@"^12.0.0 || ^12.1.0-next" shown in the above log output. This appears to be a defect within npm 7.

Several options to workaround the problem with npm 7 include:

  • passing the --force option to ng update which will propagate the force flag to npm.
  • Downgrade to npm 6
  • Switch to yarn as a package manager

@clydin clydin added the npm 7 npm 7 related issue label Jun 25, 2021
@jdussouillez
Copy link
Author

@clydin Thanks ! The --force flag did the trick.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jul 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
npm 7 npm 7 related issue
Projects
None yet
Development

No branches or pull requests

2 participants