Nx: run-migrations fails in Angular projects

Created on 17 Dec 2020  路  1Comment  路  Source: nrwl/nx

Current Behavior

Running the migrations after updating from Nx 10 to 11 fails in _all_ my Nx+Angular projects with this error:

no such file or directory, open 'C:\Users\User\Projects\playground-nx\workspace.json'

All projects have an angular.json as they are all configured to use the Angular CLI.

When debugging nx migrate --run-migrations=migrations.json, i noticed the following:

image

updateWorkspaceJsonToMatchFormatVersion in node_modules\@nrwl\workspace\src\utils\rules\format-files.js returns true for _both_ paths even though only angular.json exists.

Investigating further, we eventually arrive at isFile in node_modules\@nrwl\tao\src\commands\ngcli-adapter.js which returns true for /workspace.json even though only angular.json exists:

image

I wonder how this can work in _any_ Nx Workspace with Angular as CLI...!?

Expected Behavior

Nx migrates successfully to 11.

Steps to Reproduce

npx create-nx-workspace@10 playground-nx --preset angular --appName demo --linter tslint --style scss --nx-cloud false
cd playground-nx
npx nx migrate @nrwl/workspace@latest
npm install
nx migrate --run-migrations=migrations.json

Failure Logs

Complete log: complete-log.txt

nx migrate --run-migrations=migrations.json
Running migration update-decorate-angular-cli
Successfully finished update-decorate-angular-cli
---------------------------------------------------------
Running migration update-node-types
Failed to format: /workspace.json
Error: ENOENT: no such file or directory, open 'C:\Users\User\Projects\playground-nx\workspace.json'
    at Object.openSync (fs.js:476:3)
    at Object.readFileSync (fs.js:377:35)
    at Observable._subscribe (C:\Users\User\Projects\playground-nx\node_modules\@angular-devkit\core\node\host.js:192:35)
    at Observable._trySubscribe (C:\Users\User\Projects\playground-nx\node_modules\@angular-devkit\core\node_modules\rxjs\internal\Observable.js:44:25)
    at Observable.subscribe (C:\Users\User\Projects\playground-nx\node_modules\@angular-devkit\core\node_modules\rxjs\internal\Observable.js:30:22)
    at C:\Users\User\Projects\playground-nx\node_modules\rxjs\internal\util\subscribeToObservable.js:10:20
    at Object.subscribeToResult (C:\Users\User\Projects\playground-nx\node_modules\rxjs\internal\util\subscribeToResult.js:14:45)
    at SwitchMapSubscriber._innerSub (C:\Users\User\Projects\playground-nx\node_modules\rxjs\internal\operators\switchMap.js:65:54)
    at SwitchMapSubscriber._next (C:\Users\User\Projects\playground-nx\node_modules\rxjs\internal\operators\switchMap.js:55:14)
    at SwitchMapSubscriber.Subscriber.next (C:\Users\User\Projects\playground-nx\node_modules\rxjs\internal\Subscriber.js:66:18) {
  errno: -4058,
  syscall: 'open',
  code: 'ENOENT',
  path: 'C:\\Users\\User\\Projects\\playground-nx\\workspace.json'
}
Successfully finished update-node-types
---------------------------------------------------------
Running migration rename-workspace-schematics
Successfully finished rename-workspace-schematics
---------------------------------------------------------
Running migration add-outputs-in-workspace
ENOENT: no such file or directory, open 'C:\Users\User\Projects\playground-nx\workspace.json'
C:\Users\User\Projects\playground-nx\node_modules\yargs\build\lib\yargs.js:1132
                throw err;
                ^

Error: Command failed: npx tao migrate --run-migrations=migrations.json
    at checkExecSyncError (child_process.js:616:11)
    at Object.execSync (child_process.js:652:15)
    at Object.handler (C:\Users\User\Projects\playground-nx\node_modules\@nrwl\workspace\src\command-line\nx-commands.js:76:21)
    at Object.runCommand (C:\Users\User\Projects\playground-nx\node_modules\yargs\build\lib\command.js:196:48)
    at Object.parseArgs [as _parseArgs] (C:\Users\User\Projects\playground-nx\node_modules\yargs\build\lib\yargs.js:1043:55)
    at Object.get [as argv] (C:\Users\User\Projects\playground-nx\node_modules\yargs\build\lib\yargs.js:986:25)
    at Object.initLocal (C:\Users\User\Projects\playground-nx\node_modules\@nrwl\cli\lib\init-local.js:23:13)
    at Object.<anonymous> (C:\Users\User\Projects\playground-nx\node_modules\@nrwl\cli\bin\nx.js:41:18)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10) {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 10952,
  stdout: null,
  stderr: null
}

Environment


>  NX  Report complete - copy this into the issue template

  nx : Not Found
  @nrwl/angular : 10.4.7
  @nrwl/cli : 10.4.7
  @nrwl/cypress : 10.4.7
  @nrwl/eslint-plugin-nx : Not Found
  @nrwl/express : Not Found
  @nrwl/jest : 10.4.7
  @nrwl/linter : 10.4.7
  @nrwl/nest : Not Found
  @nrwl/next : Not Found
  @nrwl/node : Not Found
  @nrwl/react : Not Found
  @nrwl/schematics : Not Found
  @nrwl/tao : 10.4.7
  @nrwl/web : Not Found
  @nrwl/workspace : 10.4.7
  typescript : 4.0.5
bug

Most helpful comment

Thank you for reporting! Fixed it in 11.0.11.

>All comments

Thank you for reporting! Fixed it in 11.0.11.

Was this page helpful?
0 / 5 - 0 ratings