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.

Update: Invalid format version detected - Expected:[ 1 ] Found: [ 2 ]

See original GitHub issue

Current Behavior

I cannot force run NG update.

Expected Behavior

Work as described: Bildschirmfoto 2022-07-21 um 07 23 24

Steps to Reproduce

FORCE_NG_UPDATE=true pnpm nx (or ng) update @angular/{cli,core,cdk,google-maps}@latest --allow-dirty

I do not use the decorate js file because it seems odd and I never use ng commands except for this one. Sometimes this works but sometimes I get this error. Have not found out yet in which condition it works.

Failure Logs

[NX] Angular devkit readJsonWorkspace fell back to Nx workspaces logic
The installed Angular CLI version is outdated.
Installing a temporary Angular CLI versioned 14.1.0 to perform the update.
✔ Packages successfully installed.
Node.js version v17.9.1 detected.
Odd numbered Node.js versions will not enter LTS status and should not be used for production. For more information, please see https://nodejs.org/en/about/releases/.
Workspace config file cannot be loaded: /Users/marvin/Development/app/angular.json
Invalid format version detected - Expected:[ 1 ] Found: [ 2 ]
 ELIFECYCLE  Command failed with exit code 1.
FORCE_NG_UPDATE=true pnpm ng update @angular/{cli,core,cdk,google-maps}@latest --allow-dirty
Node.js version v17.9.1 detected.
Odd numbered Node.js versions will not enter LTS status and should not be used for production. For more information, please see https://nodejs.org/en/about/releases/.
Workspace config file cannot be loaded: /Users/marvin/Development/app/angular.json
Invalid format version detected - Expected:[ 1 ] Found: [ 2 ]

Environment

   Node : 17.9.1
   OS   : darwin arm64
   pnpm : 7.5.2

   nx : 14.4.3
   @nrwl/angular : 14.4.3
   @nrwl/cypress : 14.4.3
   @nrwl/detox : Not Found
   @nrwl/devkit : 14.4.3
   @nrwl/eslint-plugin-nx : 14.4.3
   @nrwl/express : Not Found
   @nrwl/jest : 14.4.3
   @nrwl/js : 14.4.3
   @nrwl/linter : 14.4.3
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : 14.4.3
   @nrwl/web : 14.4.3
   @nrwl/workspace : 14.4.3
   typescript : 4.7.3
   ---------------------------------------
   Community plugins:
   	 @ionic/angular: 6.1.14
   	 @ngneat/transloco: 4.1.1
   	 ngx-extended-pdf-viewer: 14.5.0
   	 @compodoc/compodoc: 1.1.19
   	 @ionic/angular-toolkit: 7.0.0
   	 @nxtend/capacitor: 13.0.0
   	 @nxtend/ionic-angular: 13.1.0
   	 @testing-library/angular: 12.1.0
   	 nx-stylelint: 13.5.2

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
AgentEndercommented, Sep 29, 2022

Sure, let me clarify:

you can use nx migrate @angular/core@{v}. We do not generally recommend this,

sounds confusing to me. What do you not generally recommend? Updating an especific package to an especific version using nx migrate?

That is the command that we would recommend, but for @angular/core or other angular packages we don’t tend to recommend it due to the potential incompatibilities between new versions of @angular-devkit/core and Nx. The reasoning for that is explained a bit in the rest of that paragraph above.

It seems like some kind of a feud

There isn’t a feud, we collaborate with the angular team on several things and that’s certainly not the takeaway that I am trying to give. The end result is that an Nx workspace is an Nx workspace, not an Angular CLI workspace. An Nx workspace that uses v1 schema for workspace configuration is backwards compatible with Angular CLI, where as an Nx workspace that uses v2 schema or standalone configuration files is no longer backwards compatible with the raw Angular CLI since that is a feature of the Nx CLI tool. When invoking Angular CLI outright, only features that it supports are supported. FORCE_NG_UPDATE disables any compatibility layers that we have in place when using Nx CLI, and thus fails now.

0reactions
JosepAlacidcommented, Sep 29, 2022

Sorry but:

you can use nx migrate @angular/core@{v}. We do not generally recommend this,

sounds confusing to me. What do you not generally recommend? Updating an especific package to an especific version using nx migrate?

They don’t support v2 workspaces, but we do and we support running migrations through nx migrate.

It seems like some kind of a feud; wifh NX and Angular users trying to code in the middle of the battlefield. Anyway, there’s no other option than going with those workarounds and I’m happy, less frustrated, to know it.

Even this message can be read in ugly ways, I really apreciate your guidance.

Take it as a fresh view from a new NX user who isn’t still used to the details. It can be a fresh view for those who are immersed in NX uses and standards.

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular7 - How to resolve an 'Invalid format version detected
Anyway, by luck I took a look in the angular.json file and found that it has an element named version and it was...
Read more >
Discussion on Assist - Angular 13+ Bootstrap 5+ Theme
... v2.0 folder and running ng serve command I am getting error: "An unhandled exception occurred: Invalid format version detected - Expected:[ 1...
Read more >
Angular Schematics not loading when using version 2 of ...
Angular Schematics not loading when using version 2 of angular.json (NX workspace). 2. Using version 2: image.png. Using version 1: image1.png.
Read more >
Intro to Nx
A modern Angular development experience powered by advanced generators and integrations with modern tooling. Create a Standalone Angular app. Adopting Nx.
Read more >
Angular workspace configuration
Angular CLI comes with two build configurations: production and development . By default, the ng build command uses the production configuration, which applies ......
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