nrwl / nx

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

Angular schematics broke in NX 11 #4298

Closed itayod closed 3 years ago

itayod commented 3 years ago

Current Behavior

After upgraded my workspace to NX 11 it seems that every schematics command is broken given the following error: ENOENT: no such file or directory, open 'apps\app\src\app\workspace.json'.

I also tried it on a new workspace environment but got the same results.

Expected Behavior

Angular schematics commands to work.

Steps to Reproduce

Failure Logs

$ ng g c --verbose

ENOENT: no such file or directory, open '...\projects\try\apps\app\workspace.json'
Error: ENOENT: no such file or directory, open '...\projects\try\apps\app\workspace.json'
at Object.openSync (fs.js:476:3)
at Object.readFileSync (fs.js:377:35)
at Workspaces.readWorkspaceConfiguration (...\projects\try\node_modules\@nrwl\tao\src\shared\workspace.js:19:33)
at Object.<anonymous> (...\projects\try\node_modules\@nrwl\tao\src\commands\generate.js:142:44)
at Generator.next (<anonymous>)
at ...\projects\try\node_modules\tslib\tslib.js:114:75
at new Promise (<anonymous>)
at Object.__awaiter (...\projects\try\node_modules\tslib\tslib.js:110:16)
at ...\projects\try\node_modules\@nrwl\tao\src\commands\generate.js:141:63
at Object.<anonymous> (...\projects\try\node_modules\@nrwl\tao\src\shared\params.js:10:26)

Environment

  Node : 14.15.0
  OS   : win32 x64
  npm  : 6.14.8

  nx : Not Found
  @nrwl/angular : 11.0.4
  @nrwl/cli : 11.0.4
  @nrwl/cypress : 11.0.4
  @nrwl/devkit : 11.0.4
  @nrwl/eslint-plugin-nx : Not Found
  @nrwl/express : Not Found
  @nrwl/jest : 11.0.4
  @nrwl/linter : 11.0.4
  @nrwl/nest : Not Found
  @nrwl/next : Not Found
  @nrwl/node : Not Found
  @nrwl/react : Not Found
  @nrwl/schematics : Not Found
  @nrwl/tao : 11.0.4
  @nrwl/web : Not Found
  @nrwl/workspace : 11.0.4
  typescript : 4.0.5
StringKe commented 3 years ago

nx seems to start generating without finding the correct path,the real path should be in HIDDEN_PATH/diandiantu instead of HIDDEN_PATH/diandiantu/apps/ddt/src/app

➜ ng g c --verbose
ENOENT: no such file or directory, open 'HIDDEN_PATH/diandiantu/apps/ddt/src/app/workspace.json'
Error: ENOENT: no such file or directory, open 'HIDDEN_PATH/diandiantu/apps/ddt/src/app/workspace.json'
    at Object.openSync (fs.js:476:3)
    at Object.readFileSync (fs.js:377:35)
    at Workspaces.readWorkspaceConfiguration (HIDDEN_PATH/diandiantu/node_modules/@nrwl/tao/src/shared/workspace.js:19:33)
    at Object.<anonymous> (HIDDEN_PATH/diandiantu/node_modules/@nrwl/tao/src/commands/generate.js:142:44)
    at Generator.next (<anonymous>)
    at HIDDEN_PATH/diandiantu/node_modules/tslib/tslib.js:114:75
    at new Promise (<anonymous>)
    at Object.__awaiter (HIDDEN_PATH/diandiantu/node_modules/tslib/tslib.js:110:16)
    at HIDDEN_PATH/diandiantu/node_modules/@nrwl/tao/src/commands/generate.js:141:63
    at Object.<anonymous> (HIDDEN_PATH/diandiantu/node_modules/@nrwl/tao/src/shared/params.js:10:26)
StringKe commented 3 years ago

find the problem, there is no recursion upwards to find the correct directory here. https://github.com/nrwl/nx/blob/075fe9446b16e4e5c8bba78e4cb85888e5e50fe9/packages/tao/index.ts#L76 https://github.com/nrwl/nx/blob/0875d19ad3336ee95042517accc2966c50ae97e4/packages/cli/lib/init-local.ts#L66

Applicafroguy commented 3 years ago

Have the same issue

itayod commented 3 years ago

@vsavkin thanks for the quick fix though I am not sure if that's related, but it seems like every command is now generated under the application root path, e.g. apps/my-app/src/app.

So for example, if I am trying to create a new component under apps/my-app/src/app/some/nested/folder it will be generated in apps/my-app/src/app.

Please let me know if you would like me to create a new issue with further explanation for this one.

Thanks.

itayod commented 3 years ago

@vsavkin ping

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.