angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.7k stars 11.98k forks source link

ng update @angular/cli installs angular 8.2.0-next.0 #14980

Closed viceice closed 4 years ago

viceice commented 5 years ago

🐞 Bug report

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [x] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

Yes, the previous version in which this bug was not present was: .... Updating angular cli from `8.0.6` to `8.1.0` also updates other angular packages to `8.2.0-next.0` (`next`npm tag) ### Description A clear and concise description of the problem... The cli should update to `latest` instead of `next` npm tag. ## πŸ”¬ Minimal Reproduction

create a angular workspace with angular 8.0.6 and upgrade to 8.1.0

npx -p @angular/cli@8.0.6 ng new bug
cd bug
npx -p @angular/cli@8.0.6 ng update @angular/cli

πŸ”₯ Exception or Error




Using package manager: 'yarn'
Collecting installed dependencies...
Found 81 dependencies.
Fetching dependency metadata from registry...
  Package "ng-packagr" has an incompatible peer dependency to "@angular/compiler-cli" (requires "^6.0.0 || ^7.0.0 || ^8.0.0-beta.0 || ^8.1.0-beta.0" (extended), would install "8.2.0-next.0").
  Package "@angular/cdk" has an incompatible peer dependency to "@angular/common" (requires "^8.0.0 || ^9.0.0-0" (extended), would install "8.2.0-next.0").
  Package "jest-preset-angular" has an incompatible peer dependency to "@angular/core" (requires ">=2.0.0", would install "8.2.0-next.0").
  Package "ng-packagr" has an incompatible peer dependency to "@angular/compiler" (requires "^6.0.0 || ^7.0.0 || ^8.0.0-beta.0 || ^8.1.0-beta.0" (extended), would install "8.2.0-next.0").
  Package "jest-preset-angular" has an incompatible peer dependency to "@angular/platform-browser-dynamic" (requires ">=2.0.0", would install "8.2.0-next.0").
Incompatible peer dependencies found.
Peer dependency warnings when installing dependencies means that those dependencies might not work correctly together.
You can use the '--force' option to ignore incompatible peer dependencies and instead address these warnings later.

🌍 Your Environment




Angular CLI: 8.0.6
Node: 10.15.0
OS: win32 x64
Angular: 8.1.0
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.800.6
@angular-devkit/build-angular      0.800.6
@angular-devkit/build-ng-packagr   0.800.6
@angular-devkit/build-optimizer    0.800.6
@angular-devkit/build-webpack      0.800.6
@angular-devkit/core               8.0.6
@angular-devkit/schematics         8.0.1
@angular/cdk                       8.0.2
@angular/cli                       8.0.6
@ngtools/json-schema               1.2.0
@ngtools/webpack                   8.0.6
@schematics/angular                8.0.1
@schematics/update                 0.800.6
ng-packagr                         5.3.0
rxjs                               6.5.2
typescript                         3.4.5
webpack                            4.30.0

Anything else relevant?

ErVishalM commented 5 years ago

@hpawe01 well not solved from this command also. see run this command -

ng update @angular/core @angular/cli @angular/cdk @angular/material @angular/material-moment-adapter
Using package manager: 'npm'
Collecting installed dependencies...
Found 43 dependencies.
Fetching dependency metadata from registry...
Package '@angular/core' is already up to date.
Package '@angular/cli' is already up to date.
                  Package "ag-grid-angular" has an incompatible peer dependency to "@angular/core" (requires ">=2.1.x" (extended), 
would install "9.0.0-next.2").
                  Package "ag-grid-angular" has an incompatible peer dependency to "@angular/compiler" (requires ">=2.1.x" (extended), would install "9.0.0-next.2").
Incompatible peer dependencies found.
Peer dependency warnings when installing dependencies means that those dependencies might not work correctly together.
You can use the '--force' option to ignore incompatible peer dependencies and instead address these warnings later.
mysongs commented 5 years ago

I had the exact same issue, but resolved now . following command worked.

ng update @angular/cli@8.2.1 @angular/core@8.2.1 @angular/compiler-cli@8.2.1

blogcraft commented 5 years ago

I hate ng update...

nzbin commented 5 years ago

I have the same issue when update @angular/cli 8.1.3 -> 8.2.2

Finally I update in following way:

Ploppy3 commented 5 years ago

@nzbin I'm pretty sure this would skip any automatic code migration that would be done by the ng update command. I highly recommend you not to do this, unless someone who knows more about it than me can clear things up.

JohnnyDevNull commented 5 years ago

I can confirm @nzbin case, same here from @angular/cli 8.1.3 -> 8.2.2

In my case it want to install @angular/common 9.0.0-next.2, also when only updating @angular/core

This worked for me: ng update @angular/cli@8.2.2 @angular/core@8.2.2

ErVishalM commented 5 years ago

@JohnnyDevNull I am getting the same error - ng update @angular/cli@8.2.2 @angular/core@8.2.2

Collecting installed dependencies...
Found 43 dependencies.
Package '@angular/core' is already at '8.2.2'.
Fetching dependency metadata from registry...
                  Package "ag-grid-angular" has an incompatible peer dependency to "@angular/core" (requires ">=2.1.x" (extended), 
would install "9.0.0-next.2").
                  Package "ag-grid-angular" has an incompatible peer dependency to "@angular/compiler" (requires ">=2.1.x" (extended), would install "9.0.0-next.2").
Incompatible peer dependencies found.
Peer dependency warnings when installing dependencies means that those dependencies might not work correctly together.
You can use the '--force' option to ignore incompatible peer dependencies and instead address these warnings later

Please help us to resolve this issue on priority as we are unable to update angular cli and material

IdanCo commented 4 years ago

Same issue from 7.2.14 to 8.2.2

this worked for me - ng update @angular/cli@8.2.2 @angular/core@8.2.2 @angular/compiler-cli@8.2.2

qortex commented 4 years ago

Still does not work. How are we supposed to update?

Setting the versions by hand does not work either:

ng update @angular/cdk@8.1.3 @angular/cli@8.2.2 @angular/core@8.2.2 @angular/material@8.1.3
Using package manager: 'npm'
Collecting installed dependencies...
Found 51 dependencies.
Fetching dependency metadata from registry...
                  Package "@angular/common" has an incompatible peer dependency to "@angular/core" (requires "9.0.0-next.2" (extended), would install "8.2.2").
                  Package "@angular/platform-browser-dynamic" has an incompatible peer dependency to "@angular/common" (requires "8.2.2", would install "9.0.0-next.2")
                  Package "@angular/platform-browser" has an incompatible peer dependency to "@angular/common" (requires "8.2.2", would install "9.0.0-next.2")
                  Package "@angular/common" has an incompatible peer dependency to "@angular/core" (requires "9.0.0-next.2", would install "8.2.2")
                  Package "@angular/flex-layout" has an incompatible peer dependency to "@angular/common" (requires ">=8.0.0-rc.5", would install "9.0.0-next.2").
                  Package "@angular/router" has an incompatible peer dependency to "@angular/common" (requires "8.2.2", would install "9.0.0-next.2")
                  Package "@angular/forms" has an incompatible peer dependency to "@angular/common" (requires "8.2.2", would install "9.0.0-next.2")
Incompatible peer dependencies found.
Peer dependency warnings when installing dependencies means that those dependencies might not work correctly together.
You can use the '--force' option to ignore incompatible peer dependencies and instead address these warnings later.
colmben commented 4 years ago

Guys, this is a showstopper. If this was a commercial release it would be withdrawn until this issue was resolved. As things stand, following the update instructions results in unreleased beta software being installed. You have to resolve this or pull the update instructions.

rdrrichards commented 4 years ago

@colmben A showstopper? Please! This is an inconvenience, at worst. The issue was reported over a month ago, and it hasn’t kept me from getting the proper version of Angular installed in my applications. Don’t be so dramatic.

qortex commented 4 years ago

@rdrrichards Ah great, can you expand on how you safely update all angular packages?

In good faith, I'm stuck with this ng update fail. I am not familiar enough with the inner workings of angular-cli to feel safe with just bypassing that through npm or packages.json and pray for dependencies to fall in order afterwards.

rdrrichards commented 4 years ago

Nothing magical, really. After seeing this issue come up, all I do is edit the packages.json file, and change all occurrences of 9.0.0-next.2 to 8.2.2, then run npm install.

If you're not comfortable with editing the packages.json, try to get some level of comfortable with it. Obviously, relying on the tools 100% of the time can be disappointing.

If this issue were a real show showstopper, the Angular CLI team would have had it fixed by now. Working around this is quite easy.

qortex commented 4 years ago

I don't know how you get to the point where you have 9.0.0-next.2 in packages.json, it doesn't happen to me :( (see error above)

Bypassing https://github.com/angular/angular-cli/blob/master/packages/angular/cli/commands/update-impl.ts and the rest doesn't seem trivial to me - at least I cannot safely envision the consequences.

IMO, relying on a toolchain is not a weakness but rather the basis for successful devops: having those shortcuts and not caring about the gory details is part of why I chose Angular in the first place :)

I hope a safe workaround can be found until it's fully fixed in a future release.

jtsom commented 4 years ago

Same thing just happened to me. Updated from 8.0.0 to what I thought would be 8.2.2, updated all the way to ~9.0.0-next.2. Bit of a surprise...

maroy1986 commented 4 years ago

Nothing magical, really. After seeing this issue come up, all I do is edit the packages.json file, and change all occurrences of 9.0.0-next.2 to 8.2.2, then run npm install.

If you're not comfortable with editing the packages.json, try to get some level of comfortable with it. Obviously, relying on the tools 100% of the time can be disappointing.

If this issue were a real show showstopper, the Angular CLI team would have had it fixed by now. Working around this is quite easy.

Doing that you're asking for trouble. Let me explain it a little here. When you ran ng update @angular/core and end up with the 9.0.0-next.Y versions, the CLI also ran the migration for Angular 9 on your project unless you added the flag to skip these which doesn't seem to be the case here. It's working because you got lucky. The migration didn't transition some code to something that is new in Angular 9 and not supported by 8. Otherwise, it wouldn't have worked. This is a reckless way of going around the problem that can results in much bigger problem IMO...

colmben commented 4 years ago

Nothing magical, really. After seeing this issue come up, all I do is edit the packages.json file, and change all occurrences of 9.0.0-next.2 to 8.2.2, then run npm install. If you're not comfortable with editing the packages.json, try to get some level of comfortable with it. Obviously, relying on the tools 100% of the time can be disappointing. If this issue were a real show showstopper, the Angular CLI team would have had it fixed by now. Working around this is quite easy.

Doing that you're asking for trouble. Let me explain it a little here. When you ran ng update @angular/core and end up with the 9.0.0-next.Y versions, the CLI also ran the migration for Angular 9 on your project unless you added the flag to skip these which doesn't seem to be the case here. It's working because you got lucky. The migration didn't transition some code to something that is new in Angular 9 and not supported by 8. Otherwise, it wouldn't have worked. This is a reckless way of going around the problem that can results in much bigger problem IMO...

This is exactly what happened to me, it updated 30+ source files beyond the 3 that actually needed updating for 8. All quite scary and time consuming for what should be a simple enough framework update. I did exactly what rdrrichards suggests and so now I have an app that is using 8 but migrated to 9. It seems to be working, but I haven't diff'ed all 30+ files yet to understand what the implications are. For a commercial developer this is all time wasted that could have been spent writing code - the exact point of using a framework like Angular in the first place. Obviously we all have different definitions of what is a showstopper, but releasing an update procedure that causes unreleased beta code to be loaded onto your client severs and all your client's code go through an unreleased migration process seems to me to fall within that category.

mgechev commented 4 years ago

Hey folks, we're aware of this problem and @clydin is looking into it. Since the discussion is getting a bit heated, I'll lock the issue temporarily until we have some progress. Excuse us for the inconvenience and thank you for your patience!

Side note: if you're already on version 8.x, updating your package.json to the latest Angular version should be fine. We haven't shipped any changes that require automatic migration (codemods).

vikerman commented 4 years ago

This should be resolved now in latest 8.3.x builds.