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

ng update deletes node_modules before ensuring it will succeed #22162

Open
1 of 15 tasks
ericeslinger opened this issue Nov 14, 2021 · 4 comments
Open
1 of 15 tasks

ng update deletes node_modules before ensuring it will succeed #22162

ericeslinger opened this issue Nov 14, 2021 · 4 comments
Labels
Milestone

Comments

@ericeslinger
Copy link

🐞 Bug report

Command (mark with an x)

ng update @angular/cli @angular/cdk ...

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

Is this a regression?

Not sure. Might be half bug, half feature request.

Description

When updating from angular 12 to 13, the following sequence of events happened:

  1. ng update to determine dependencies
  2. ng update ...
  3. after determining dependencies and updating my package.json file, the script seems to delete node_modules
  4. the npm install step triggered by ng update fails due to a peer dependency conflict
  5. this is the FR/bug this part of the script should do a dry run and abort before deleting node_modules if the npm install with the updated package.json file will fail. Ideally add more details and suggestions here, and roll back the change to package.json.
  6. Now re-running ng update a second time will note no installed dependencies, because apparently the script checks node_modules and not package.json.
  7. The actual fix for the deeper bug is some conflict in peer dependencies between the older 12 installation of architect and build-angular and the updated package.json file. Reverting package.json to head (the 12 installation), running npm install to re-install the now-missing node_modules directory, then deleting package-lock.json, will allow the ng update command to run to completion. If this is a common issue, adding some help text in that regard would be nice.

🌍 Your Environment

NOTE this is post-upgrade, the bug happened during a 12->13 upgrade.


Angular CLI: 13.0.2
Node: 16.10.0
Package Manager: npm 7.24.0
OS: linux x64

Angular: 13.0.1
... animations, cdk, common, compiler, compiler-cli, core, forms
... material, platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1300.2
@angular-devkit/build-angular   13.0.2
@angular-devkit/core            13.0.2
@angular-devkit/schematics      13.0.2
@angular/cli                    13.0.2
@angular/fire                   7.2.0
@schematics/angular             13.0.2
rxjs                            6.6.7
typescript                      4.4.4

Anything else relevant?

@alan-agius4 alan-agius4 added area: @angular/cli ng update DX feature Issue that requests a new feature labels Nov 15, 2021
@ngbot ngbot bot modified the milestone: Backlog Nov 15, 2021
@ardunster
Copy link

I had an issue with this also, didn't think of rerunning update after deleting the contents of package.json, I ended up copying them to another location and installing them a few at a time with the new version. Something involving @angular-devkit/build-angular has a bad peer dependency listed. I thought I had a log file to share but it inadvertently got overwritten.

@asteidle70
Copy link

asteidle70 commented Dec 2, 2021

Same issue with update from Angular 10 to 11. node_modules folder gone! :( :(

From https://update.angular.io/?l=2&v=10.0-12.0
npx @angular/cli@11 update @angular/core@11 @angular/cli@11
Only issues a one-line error message "Repository is not clean. ...". But I am not even using git.
Stackoverflow suggests to add --allow-dirty
It runs with that. I get
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
Not sure if that is important.
Then plenty of errors related to @angular-devkit/build-angular@0.1000.4

npm ERR! While resolving: workspace@0.0.0
npm ERR! Found: @angular-devkit/build-angular@0.1000.4
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR!   dev @angular-devkit/build-angular@"~0.1102.15" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! dev @angular-devkit/build-angular@"~0.1102.15" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @angular/compiler-cli@11.2.14
npm ERR! node_modules/@angular/compiler-cli
npm ERR!   peer @angular/compiler-cli@"^11.0.0 || ^11.2.0-next" from @angular-devkit/build-angular@0.1102.15
npm ERR!   node_modules/@angular-devkit/build-angular
npm ERR!     dev @angular-devkit/build-angular@"~0.1102.15" 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 C:\Users\andreas2\AppData\Local\npm-cache\eresolve-report.txt for a full report.

eresolve-report.txt

@angular-robot angular-robot bot added the feature: votes required Feature request which is currently still in the voting phase label Feb 1, 2022
@ngbot ngbot bot modified the milestones: Backlog, needsTriage Feb 1, 2022
@Den-dp
Copy link

Den-dp commented Feb 17, 2022

I think that removing a node_modules folder is:

  • time-consuming
  • counter-productive (my understanding is: npm heavily relies on a package-lock.json while installing, so removing node_modules brings to us very little or nothing in terms of a profit)

@angular-robot angular-robot bot added feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors and removed feature: votes required Feature request which is currently still in the voting phase labels Feb 22, 2022
@nikita-fuchs

This comment was marked as outdated.

@alan-agius4 alan-agius4 added severity2: inconvenient type: bug/fix freq1: low Only reported by a handful of users who observe it rarely and removed feature Issue that requests a new feature feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors labels Oct 5, 2023
@angular angular deleted a comment from angular-robot bot Oct 5, 2023
@angular angular deleted a comment from angular-robot bot Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants