question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Migration failed: Cannot read property 'Loose' of undefined

See original GitHub issue

🐞 Bug report

Command (mark with an x)

ng update @angular/cli --from 8 --to 9 --migrate-only

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

Is this a regression?

Yes, the previous version in which this bug was not present was: Migrating from angular 7 to 8

Description

** Executing migrations of package β€˜@angular/cli’ **

Replace deprecated β€˜styleext’ and β€˜spec’ Angular schematic options. Γ— Migration failed: Cannot read property β€˜Loose’ of undefined

πŸ”¬ Minimal Reproduction

I can only reproduce it on this one project I’ve upgraded another angular project without any issues

πŸ”₯ Exception or Error



[error] TypeError: Cannot read property 'Loose' of undefined
    at readJsonFileAsAstObject (~\node_modules\@angular\cli\node_modules\@schematics\angular\migrations\update-9\utils.js:90:74)
    at Object.getWorkspace (~\node_modules\@angular\cli\node_modules\@schematics\angular\migrations\update-9\utils.js:77:21)
    at ~\node_modules\@angular\cli\node_modules\@schematics\angular\migrations\update-9\schematic-options.js:15:35
    at MergeMapSubscriber.project ({userDir}\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@angular-devkit\schematics\src\rules\call.js:75:24)
    at MergeMapSubscriber._tryNext ({userDir}\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\rxjs\internal\operators\mergeMap.js:67:27)
    at MergeMapSubscriber._next ({userDir}\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\rxjs\internal\operators\mergeMap.js:57:18)
    at MergeMapSubscriber.Subscriber.next ({userDir}\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\rxjs\internal\Subscriber.js:66:18)
    at Observable._subscribe ({userDir}\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\rxjs\internal\util\subscribeToArray.js:5:20)
    at Observable._trySubscribe ({userDir}\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\rxjs\internal\Observable.js:44:25)
    at Observable.subscribe ({userDir}\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\rxjs\internal\Observable.js:30:22)

🌍 Your Environment



Angular CLI: 10.2.3
Node: 14.18.1
OS: win32 x64

Angular: 10.2.5
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router
Ivy Workspace: Yes

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.13.10
@angular-devkit/build-angular      0.1002.3
@angular-devkit/core               7.3.10
@angular-devkit/schematics         10.2.3
@angular/cdk                       10.2.7
@angular/cli                       10.2.3
@angular/material                  10.2.7
@angular/material-moment-adapter   10.2.7
@schematics/angular                7.3.10
@schematics/update                 0.13.10
rxjs                               7.4.0
typescript                         3.9.10

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:32

github_iconTop GitHub Comments

6reactions
PahanPereracommented, Nov 8, 2021

Hi, I think when you run npx @angular/cli@9 update @angular/core@9 @angular/cli@9, it supposes to install the @angular/cli@9 in your local node_modules and run update command against that version. For some reason it is not happening as expected.

These are the steps that I followed and I was able to migrate Angular 8 application to Angular 9 without any errors.

  1. Make sure your project is clean (delete node_modules and package-lock.json file if required and do a fresh npm install)
  2. Install target @angular/cli version in your local (in this case run npm install -D @angular/cli@9)
  3. Now run update command against the local cli (npx ng update @angular/core@9 @angular/cli@9 - you might need to use --force and --allow-dirty based on your project)

This should migrate your application successfully to the target version.

(My Node Version v12.20.1, NPM is 6.13.4, Global ng version is 8.3.25 )

2reactions
alan-agius4commented, Nov 4, 2021

I was able to replicate this issue. As a workaround you can use the following command.

NG_DISABLE_VERSION_CHECK=1 ./node_modules/.bin/ng update @angular/cli --from 8 --to 9 --migrate-only
Read more comments on GitHub >

github_iconTop Results From Across the Web

Migration failed: Cannot read property 'Loose' of undefined
/11/04 Migration failed: Cannot read property 'Loose' of undefined # Closed. I got a problem while building a test demo, it said "Module...
Read more >
Cannot read property 'loose' of undefined babel 7 - Menubar
This error message is associated with Babel7. The cause of the error is mixing Babel 6 and Babel 7. Babel 7 is incompatible...
Read more >
angular - Cannot read properties of undefined (reading 'kind')
As you can see, angular is trying to read property "kind" from some other value. So perhaps somewhere in your code, you have...
Read more >
Angular 12 Support #14909 - Issuehunt
Could not get angular cli webpack config ERR! TypeError: Cannot read property 'minify' of undefined ERR! at getCommonConfigΒ ...
Read more >
Babel - Storybook
Storybook's frameworks and addons may provide minor programmatic modifications to the babel configuration. How it works. To activate V7 mode, set the featureΒ ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found