Failed Migration During Upgrade from Angular 9 to Angular 10
🐞 Bug report
Command
- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [x] update
- [ ] lint
- [ ] extract-i18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
Is this a regression?
N/A
Description
When upgrading from Angular 9 to Angular 10, one of the automatic migrations fails.
🔬 Minimal Reproduction
$ git clone -b feature https://github.com/ebenh/ngx-mat-tel-input.git
$ npm install
$ npx @angular/cli@10 update @angular/core@10 @angular/cli@10 --force
🔥 Exception or Error
✖ Migration failed: Cannot read properties of undefined (reading 'Loose')
See "/tmp/ng-5dsb1D/angular-errors.log" for further details.
Contents of /tmp/ng-5dsb1D/angular-errors.log
[error] TypeError: Cannot read properties of undefined (reading 'Loose')
at readJsonFileAsAstObject (/home/eben/Repositories/foo/ngx-mat-tel-input/node_modules/@schematics/angular/migrations/update-9/utils.js:90:74)
at Object.getWorkspace (/home/eben/Repositories/foo/ngx-mat-tel-input/node_modules/@schematics/angular/migrations/update-9/utils.js:77:21)
at /home/eben/Repositories/foo/ngx-mat-tel-input/node_modules/@schematics/angular/migrations/update-9/schematic-options.js:15:35
at MergeMapSubscriber.project (/tmp/angular-cli-packages-xt8UYc/node_modules/@angular-devkit/schematics/src/rules/call.js:75:24)
at MergeMapSubscriber._tryNext (/tmp/angular-cli-packages-xt8UYc/node_modules/rxjs/internal/operators/mergeMap.js:67:27)
at MergeMapSubscriber._next (/tmp/angular-cli-packages-xt8UYc/node_modules/rxjs/internal/operators/mergeMap.js:57:18)
at MergeMapSubscriber.Subscriber.next (/tmp/angular-cli-packages-xt8UYc/node_modules/rxjs/internal/Subscriber.js:66:18)
at Observable._subscribe (/tmp/angular-cli-packages-xt8UYc/node_modules/rxjs/internal/util/subscribeToArray.js:5:20)
at Observable._trySubscribe (/tmp/angular-cli-packages-xt8UYc/node_modules/rxjs/internal/Observable.js:44:25)
at Observable.subscribe (/tmp/angular-cli-packages-xt8UYc/node_modules/rxjs/internal/Observable.js:30:22)
🌍 Your Environment
Output of npx ng --version
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 10.2.3
Node: 16.13.0
OS: linux x64
Angular: 10.2.5
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes
Package Version
------------------------------------------------------------
@angular-devkit/architect 0.1002.3
@angular-devkit/build-angular 0.1002.3
@angular-devkit/build-ng-packagr 0.1002.3
@angular-devkit/core 10.2.3
@angular-devkit/schematics 10.2.3
@angular/cdk 9.2.4
@angular/cli 10.2.3
@angular/flex-layout 12.0.0-beta.34
@angular/material 9.2.4
@schematics/angular 10.2.3
@schematics/update 0.1002.3
ng-packagr 10.1.2
rxjs 6.5.5
typescript 4.0.8
Duplicate of https://github.com/angular/angular-cli/issues/22085
Duplicate of #22085
Thanks. This was helpful.
In case it helps someone else, you can find the steps to resolve the issue below.
The first line upgrades @angular/core and @angular/cli from version 9 to version 10 (expect an error). The second line runs the migrations.
$ npx @angular/cli@10 update @angular/core@10 @angular/cli@10 -- force
$ NG_DISABLE_VERSION_CHECK=1 ./node_modules/.bin/ng update @angular/cli --from 9 --to 10 --migrate-only
Not working:

Not working:
The syntax of the command snippet above is compatible with Bash and other similar shells. You need to modify it for PowerShell.
Specifically, PowerShell is complaining because of how you're setting the shell variable NG_DISABLE_VERSION_CHECK.
You need to look up how to set shell/environment variables in PowerShell.
Thanks! It worked on gitbash.

Can you help me to execute below command in Windows 10?
NG_DISABLE_VERSION_CHECK=1 ./node_modules/.bin/ng update @angular/cli --from 9 --to 10 --migrate-only
NG_DISABLE_VERSION_CHECK=1 ./node_modules/.bin/ng update @angular/cli --from 8 --to 9 --migrate-only
I think it works on a linux terminal and i do not know how it can be executed on Windows.
As really dirty workaround edit the ./node_modules/.bin/ng.cmd file and put SET NG_DISABLE_VERSION_CHECK=1 in the first lines of the file (i.e. after SETLOCAL).
Then run ./node_modules/.bin/ng.cmd update @angular/cli.cmd --from 8 --to 9 --migrate-only
Notice that it happens also for migration between 9 and 10
I solved running on git bash with force and allow dirty
Obter o Outlook para Androidhttps://aka.ms/AAb9ysg
From: Edmondo Di Tucci @.> Sent: Monday, November 8, 2021 5:54:20 AM To: angular/angular-cli @.> Cc: Rômulo Sorato @.>; Comment @.> Subject: Re: [angular/angular-cli] Failed Migration During Upgrade from Angular 9 to Angular 10 (Issue #22094)
NG_DISABLE_VERSION_CHECK=1 ./node_modules/.bin/ng update @angular/cli --from 8 --to 9 --migrate-only
I think it works on a linux terminal and i do not know how it can be executed on Windows. As really dirty workaround edit the ./node_modules/.bin/ng.cmd file and put SET NG_DISABLE_VERSION_CHECK=1 in the first lines of the file (i.e. after SETLOCAL). Then run ./node_modules/.bin/ng.cmd update @angular/cli.cmd --from 8 --to 9 --migrate-only
Notice that it happens also for migration between 9 and 10
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/angular/angular-cli/issues/22094#issuecomment-962936068, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAKDV7AZKWNZZRPE3QHUVZTUK6F3ZANCNFSM5HMOGE4A. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
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.