nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.63k stars 2.36k forks source link

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

Closed muuvmuuv closed 2 years ago

muuvmuuv commented 2 years ago

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
AgentEnder commented 2 years ago

FORCE_NG_UPDATE doesn't work in v2 workspaces, because angular CLI can't read them.

People used to use ng update instead of nx migrate sometimes because of packageGroup support, but Nx supports it now. Is there a reason you are still using ng update that we could resolve?

ElecTreeFrying commented 2 years ago

FORCE_NG_UPDATE doesn't work in v2 workspaces, because angular CLI can't read them.

People used to use ng update instead of nx migrate sometimes because of packageGroup support, but Nx supports it now. Is there a reason you are still using ng update that we could resolve?

I'm getting this error in ng update... how to solve this issue?

Workspace config file cannot be loaded: :\\angular.json Invalid format version detected - Expected:[ 1 ] Found: [ 2 ]

AgentEnder commented 2 years ago

FORCE_NG_UPDATE doesn't work in v2 workspaces, because angular CLI can't read them.

muuvmuuv commented 2 years ago

For minor updates. We do update cycles every first in the month. I could wait for the nx migrate command to update Angular but for minor updates I dont see any reason when there are no migrations and I just want to benefit from bug fixes and small improvements.

ElecTreeFrying commented 2 years ago

FORCE_NG_UPDATE doesn't work in v2 workspaces, because angular CLI can't read them. People used to use ng update instead of nx migrate sometimes because of packageGroup support, but Nx supports it now. Is there a reason you are still using ng update that we could resolve?

I'm getting this error in ng update... how to solve this issue?

Workspace config file cannot be loaded: :\angular.json Invalid format version detected - Expected:[ 1 ] Found: [ 2 ]

btw I already resolved this issue by changing "version": 2, to "version": 1, in angular.json

just return it to "version": 2, after successful update,

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏

JosepAlacid commented 2 years ago

The issue persists. Does'nt have recent activity, but it isn't solved. There is a workaround, but NX prestige can't be based on such stains.

AgentEnder commented 2 years ago

You do not need to use ng update. nx migrate should satisfy any use that you would use ng update for.

The use case above of wanting to update an angular minor version, you can use nx migrate @angular/core@{v}. We do not generally recommend this, because nx interfaces with angular's CLI in ways that are not guaranteed to work even if the changes made in @angular-devkit/core are not technically breaking.

Definitely feel free to run the command, do some testing, and see if anything is broken... But there should be no reason to use FORCE_NG_UPDATE...

To be 100% clear, the reason that FORCE_NG_UPDATE doesn't work in v2 workspaces, is that

angular CLI can't read them

At the implementation level, FORCE_NG_UPDATE diverts your command away from nx, and goes straight through angular CLI. No patches. If angular CLI doesn't support something, it won't work. They don't support v2 workspaces, but we do and we support running migrations through nx migrate.

If something is not working with nx migrate, a new issue should be filed detailing what is currently not working, s.t. it can be properly addressed.

JosepAlacid commented 2 years ago

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.

AgentEnder commented 2 years ago

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.

github-actions[bot] commented 1 year ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.