nrwl / nx

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

ERROR Only workspace's with version 2+ support project.json files #6189

Closed batbrain9392 closed 3 years ago

batbrain9392 commented 3 years ago

Current Behavior

On running npx nx g @nrwl/workspace:convert-to-nx-project, I get this error - Only workspace's with version 2+ support project.json files

Expected Behavior

It should create the per-project config. Is this a regression? - No

Steps to Reproduce

  1. Create an Nx 12.5 project with npx create-nx-workspace --preset=angular (uses npm, not yarn)
  2. Add 2 Angular apps - Shell & Feature
  3. Add module federation with @angular-architects/module-federation
  4. Run npx nx g @nrwl/workspace:convert-to-nx-project --project shell

You could try it on this example repo.

Failure Logs

ERROR Only workspace's with version 2+ support project.json files.

Environment

Node : 14.17.1 OS : linux x64 npm : 6.14.13

nx : Not Found @nrwl/angular : 12.5.0 @nrwl/cli : 12.5.0 @nrwl/cypress : 12.5.0 @nrwl/devkit : 12.5.0 @nrwl/eslint-plugin-nx : 12.5.0 @nrwl/express : Not Found @nrwl/jest : 12.5.0 @nrwl/linter : 12.5.0 @nrwl/nest : Not Found @nrwl/next : Not Found @nrwl/node : Not Found @nrwl/react : Not Found @nrwl/schematics : Not Found @nrwl/tao : 12.5.0 @nrwl/web : Not Found @nrwl/workspace : 12.5.0 @nrwl/storybook : 12.5.0 @nrwl/gatsby : Not Found typescript : 4.2.4

tfalvo commented 3 years ago

I have the same issue just now!

On my side, I'm still using angular.json (or workspace.json with version=1). So I think we should upgrade workspace.json to version 2. But if yes, the question is how to do this ?

Anybody has some tips to do that smoothly ? (need to rename architects to generators....) Thanks!

tfalvo commented 3 years ago

oh... I renamed angular.json to workspace.json, as described in docs

Then changed version:1 to version:2 Then nx g @nrwl/workspace:convert-to-nx-project --all was working, and converted all projects. (press Enter without any name of project)

Each project configuration was moved to project.json with also new syntax (executors, generators...)

yharaskrik commented 3 years ago

Tacking on here (let me know if it should be it's own issue) when using Angular.json and migrating apps to the new project.json format (after changing version in angular.json to 2) I get Unable to read workspace file 'angular.json': Invalid format version detected - Expected:[ 1 ] Found: [ 2 ]

markhus-aurelius commented 3 years ago

Tacking on here (let me know if it should be it's own issue) when using Angular.json and migrating apps to the new project.json format (after changing version in angular.json to 2) I get Unable to read workspace file 'angular.json': Invalid format version detected - Expected:[ 1 ] Found: [ 2 ]

Was having the same issue. Renaming angular.json to workspace.json got this working for me

raeffs commented 3 years ago

That worked for me too.

However, once I add a new project with the @nrwl/angular:library schematic it basically undoes all the changes, even if I specify the standaloneConfig flag. Does anyone else have the same problem?

batbrain9392 commented 3 years ago

In the new version 12.5.1, The error messages were improved -

NX Only workspaces with version 2+ support project.json files.
To upgrade change the version number at the top of angular.json and run 'nx format'.

v2+ Required

Now, simply changing version 1 to 2 in angular.json and then running npx nx g @nrwl/workspace:convert-to-nx-project --all works.

Q: Which also begs the question, what's the benefit of renaming angular.json to workspace.json? A: Otherwise, the project straight out won't run. Also, Nx Console won't recognise the projects.

markhus-aurelius commented 3 years ago

That worked for me too.

However, once I add a new project with the @nrwl/angular:library schematic it basically undoes all the changes, even if I specify the standaloneConfig flag. Does anyone else have the same problem?

yep, the standaloneConfig flag has no affect for me either

tfalvo commented 3 years ago

Ok for me, by following @batbrain9392 instructions. Angular.json => Workspace.json v2 All project.json created.

After 12.5.1 fix, it works smoothly ! Great. Thanks!

tomalaforge commented 3 years ago

You still have to rename your angular.json into workspace.json even in 12.5.1 and even after doing a nx format. Otherwise everything is working fine into VSCode.

But using bitbucket pipeline, I've got this error when doing npx nx run-many --all --target=test --parallel Error: ENOENT: no such file or directory, open '/opt/atlassian/pipelines/agent/build/apps\xxx/project.json'

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.