nrwl / nx

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

Unable to update NX to latest version - No such file or directory error #2120

Closed demisx closed 4 years ago

demisx commented 4 years ago

Expected Behavior

Updating Nx following https://nx.dev/angular/guides/update guide goes without errors.

Current Behavior

My current workspace version is 8.7.1. I've attempted to update it to the latest following the guide on https://nx.dev/angular/guides/update, but got the following error:

$ npx nx migrate @nrwl/workspace
Fetching meta data about packages.
It may take a few minutes.
Fetching @nrwl/workspace@latest
Fetching @ngrx/store@8.5.0
Fetching @ngrx/effects@8.5.0
Fetching @ngrx/entity@8.5.0
Fetching @ngrx/router-store@8.5.0
Fetching @ngrx/schematics@8.5.0
Fetching @ngrx/store-devtools@8.5.0
Fetching @angular-devkit/architect@0.803.14
Fetching @angular-devkit/build-angular@0.803.14
Fetching @angular-devkit/build-ng-packagr@0.803.14
Fetching @angular-devkit/build-webpack@0.803.14
Fetching @angular-devkit/core@8.3.14
Fetching @angular-devkit/schematics@8.3.14
Fetching @angular/cli@8.3.14
Fetching @angular/common@8.2.12
Fetching @angular/compiler@8.2.12
Fetching @angular/compiler-cli@8.2.12
Fetching @angular/core@8.2.12
Fetching @angular/platform-browser@8.2.12
Fetching @angular/platform-browser-dynamic@8.2.12
Fetching @angular/router@8.2.12
Fetching @angular/upgrade@8.2.12
Fetching @schematics/angular@8.3.14
Fetching @nrwl/angular@undefined
Fetching @nrwl/cypress@undefined
Fetching @nrwl/eslint-plugin-nx@undefined
Fetching @nrwl/express@undefined
Fetching @nrwl/jest@undefined
Fetching @nrwl/linter@undefined
Fetching @nrwl/nest@undefined
Fetching @nrwl/next@undefined
Fetching @nrwl/node@undefined
Fetching @nrwl/react@undefined
Fetching @nrwl/tao@undefined
Fetching @nrwl/web@undefined
ENOENT: no such file or directory, open '/var/folders/yn/tfydvv613h95b9364681z6k00000gn/T/tmp-25830QNp94WeWCI3j/node_modules/@angular/cli/@schematics/angular/migrations/migration-collection.json'
Command failed: ./node_modules/.bin/tao migrate @nrwl/workspace
$ npx nx report
  @nrwl/angular : Not Found
  @nrwl/cli : 8.7.1
  @nrwl/cypress : Not Found
  @nrwl/eslint-plugin-nx : Not Found
  @nrwl/express : Not Found
  @nrwl/jest : 8.7.1
  @nrwl/linter : 8.7.1
  @nrwl/nest : 8.7.1
  @nrwl/next : Not Found
  @nrwl/node : 8.7.1
  @nrwl/react : Not Found
  @nrwl/schematics : Not Found
  @nrwl/tao : 8.7.1
  @nrwl/web : Not Found
  @nrwl/workspace : 8.7.1
  typescript : 3.5.3
demisx commented 4 years ago

Well, this error went away after installing npm i @nrwl/tao --save-dev manually. I would think this would be automatically handled for me (Nx release page doesn't mention any breaking changes updating from v8.7.x to v8.8.3), so not sure if I did the right thing here. I also had to resolve a few peer dependencies for the projects to build again. Here are the results of the latest update command. Not sure if reported absence of @schematics/angular/migrations/migration-collection.json is expected when migrating a small repo from v8.7.1 -> v8.8.3. Please let me know if you think this update went well and I'll close the issue. Thank you.

npx nx migrate @nrwl/workspace
Fetching meta data about packages.
It may take a few minutes.
Fetching @nrwl/workspace@latest
Fetching @angular-devkit/architect@0.803.14
Fetching @angular-devkit/build-angular@0.803.14
Fetching @angular-devkit/build-webpack@0.803.14
Fetching @angular-devkit/core@8.3.14
Fetching @angular-devkit/schematics@8.3.14
Fetching @angular/cli@8.3.14
Could not find '@schematics/angular/migrations/migration-collection.json' in '@angular/cli'. Skipping it
Fetching @angular/compiler@8.2.12
Fetching @angular/compiler-cli@8.2.12
Fetching @schematics/angular@8.3.14
Fetching @nrwl/jest@8.8.3
Fetching @nrwl/linter@8.8.3
Fetching @nrwl/nest@8.8.3
Fetching @nrwl/node@8.8.3
Fetching @nrwl/tao@8.8.3
Fetching @nrwl/workspace@8.8.3
The migrate command has run successfully.
- package.json has been updated
- there are no migrations to run, so migrations.json has not been created.
$ npx nx report
  @nrwl/angular : Not Found
  @nrwl/cli : 8.8.3
  @nrwl/cypress : Not Found
  @nrwl/eslint-plugin-nx : Not Found
  @nrwl/express : Not Found
  @nrwl/jest : 8.8.3
  @nrwl/linter : 8.8.3
  @nrwl/nest : 8.8.3
  @nrwl/next : Not Found
  @nrwl/node : 8.8.3
  @nrwl/react : Not Found
  @nrwl/schematics : Not Found
  @nrwl/tao : 8.8.3
  @nrwl/web : Not Found
  @nrwl/workspace : 8.8.3
  typescript : 3.5.3
vsavkin commented 4 years ago

We had an issue with the migration command. It has been fixed. You can do the following:

"npm i @nrwl/workspace@8.8.3 --save-dev"
nx migrate @nrwl/workspace@8.8.3 --from="@nrwl/workspace@8.7.1" 
GreedyA1 commented 4 years ago

@vsavkin If I run

"npm i @nrwl/workspace@8.8.3 --save-dev"
nx migrate @nrwl/workspace@8.8.3 --from="@nrwl/workspace@8.7.0" 

note I am updating from 8.7.0 I still get error. but this time I get :

Fetching @nrwl/angular@8.8.3
Fetching @nrwl/cypress@8.8.3
Fetching @nrwl/jest@8.8.3
Fetching @nrwl/tao@8.8.3
Invalid Version: 5.2
C:\Users\admin\Desktop\medicalreviewsystem\supplier-ui\src\main\web\node_modules\yargs\yargs.js:1109
      else throw err
GreedyA1 commented 4 years ago

I ended up updating package.json by hand. changed all nrwl 8.7.0 versions to 8.8.3. Also changed cypress to 3.5.0 since I was getting error on windows (cypress Issue 5241)

cladera commented 4 years ago

Experiencing the same issue. In my case I'm upgrading from @nrwl/workspace@8.6.

I ran: npm i @nrwl/workspace@8.8.3 --save-dev and then npm run nx -- migrate @nrwl/workspace@8.8.3 --from="@nrwl/workspace@8.6.0". This is the result:

Fetching meta data about packages.
It may take a few minutes.
Fetching @nrwl/workspace@8.8.3
Fetching @nrwl/angular@8.8.3
Fetching @nrwl/cypress@8.8.3
Fetching @nrwl/jest@8.8.3
Fetching @nrwl/linter@8.8.3
Fetching @nrwl/node@8.8.3
Fetching @nrwl/tao@8.8.3
Fetching @ngrx/store@8.5.0
Fetching @ngrx/effects@8.5.0
Fetching @ngrx/router-store@8.5.0
Fetching @ngrx/schematics@8.5.0
Fetching @ngrx/store-devtools@8.5.0
Fetching @angular-devkit/architect@0.803.14
Fetching @angular-devkit/build-angular@0.803.14
Fetching @angular-devkit/build-ng-packagr@0.803.14
Fetching @angular-devkit/build-webpack@0.803.14
Fetching @angular-devkit/core@8.3.14
Fetching @angular-devkit/schematics@8.3.14
Fetching @angular/cli@8.3.14
Could not find '@schematics/angular/migrations/migration-collection.json' in '@angular/cli'. Skipping it
Fetching @angular/common@8.2.12
Fetching @angular/compiler@8.2.12
Fetching @angular/compiler-cli@8.2.12
Fetching @angular/core@8.2.12
Fetching @angular/platform-browser@8.2.12
Fetching @angular/platform-browser-dynamic@8.2.12
Fetching @angular/router@8.2.12
Fetching @schematics/angular@8.3.14
Invalid Version: 5.2
/Users/cgcladera/Projects/@vancast/vancast-cloud-video/node_modules/@nrwl/workspace/node_modules/yargs/yargs.js:1109
      else throw err
           ^

Error: Command failed: ./node_modules/.bin/tao migrate @nrwl/workspace@8.8.3 --from=@nrwl/workspace@8.6.0
    at checkExecSyncError (child_process.js:621:11)
    at Object.execSync (child_process.js:658:15)
    at Object.handler (/Users/cgcladera/Projects/@vancast/vancast-cloud-video/node_modules/@nrwl/workspace/src/command-line/nx-commands.js:99:21)
    at Object.runCommand (/Users/cgcladera/Projects/@vancast/vancast-cloud-video/node_modules/@nrwl/workspace/node_modules/yargs/lib/command.js:235:44)
    at Object.parseArgs [as _parseArgs] (/Users/cgcladera/Projects/@vancast/vancast-cloud-video/node_modules/@nrwl/workspace/node_modules/yargs/yargs.js:1022:30)
    at Object.get [as argv] (/Users/cgcladera/Projects/@vancast/vancast-cloud-video/node_modules/@nrwl/workspace/node_modules/yargs/yargs.js:965:21)
    at Object.initLocal (/Users/cgcladera/Projects/@vancast/vancast-cloud-video/node_modules/@nrwl/cli/lib/init-local.js:18:26)
    at Object.<anonymous> (/Users/cgcladera/Projects/@vancast/vancast-cloud-video/node_modules/@nrwl/cli/bin/nx.js:9:18)
    at Module._compile (internal/modules/cjs/loader.js:774:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10) {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 46296,
  stdout: null,
  stderr: null
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vancast-cloud-video@4.0.0-rc.15 nx: `nx "migrate" "@nrwl/workspace@8.8.3" "--from=@nrwl/workspace@8.6.0"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the vancast-cloud-video@4.0.0-rc.15 nx script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/cgcladera/.npm/_logs/2019-12-20T08_48_47_104Z-debug.log

Before I found this issue I just tried npm run nx -- migrate @nrwl/workspace and I got the same error although les "verbose". Just got "Invalid Version: null".

vsavkin commented 4 years ago

Sorry folks. It took us a few iterations to fix the migrate command, but it's a lot more stable now. If you try the same with Nx 8.12.7 or Nx 9.0.2, you should not see any problems migrating.

I understand that you might have migrated manually by now. If that's the case, I'm going to close the issue.

alfonsobravi commented 4 years ago

I am running nx migrate --run-migrations=migrations.json after workspace migrate has succesfully migrated from 8.11.1 to @latest (9.0.2) and getting:

Running migration @nrwl/cypress:update-8.12.0
Schematic "update-8.12.0" not found in collection "@nrwl/cypress".
...
Error: Command failed: .\node_modules\.bin\tao migrate --run-migrations=migrations.json

Anyone else?

Tre665 commented 4 years ago

@alfonsobravi I had this issue in a previous migration. What it solved for me was to install the package @nrwl/tao by hand and then rerun the migration. We started with nx pretty early on and this package was added sometime when there was the transation from angular cli only to nx cli afaik. I also used to update just with yarn update, maybe that was also the reason why this package was missing for us. To be totally honest, I am to this day not sure what the preferred way is to keep the repo up to date. I thought now the migrate command should be preferred. But on the release blog (for example here it always states to just use yarn update.

alfonsobravi commented 4 years ago

@Tre665 suggestion worked out fine for me, many thanks!

jaysoo commented 4 years ago

@Tre665 You should be using nx migrate latest to keep up to date. It is a lot more stable now, and we'll likely make yarn update run the same command -- it already does for non-Angular workspaces.

Tre665 commented 4 years ago

@jaysoo Thank you for the clarification! In the last update we run just yarn update again (cause we thought that the difference would be just that it automatically runs the migration). Will update our internal docs with your recommendation.

demisx commented 4 years ago

@jaysoo The Updating NX docs show command as nx migrate @nrwl/workspace. Is nx migrate latest now preferred or are they the same?

jaysoo commented 4 years ago

@demisx They are basically the same. nx migrate latest is basically nx migrate @nrwl/workspace@latest (we default the package to @nrwl/workspace if you don't specify it).

demisx commented 4 years ago

@jaysoo Got it. Thank you for clarifying it.

demisx commented 4 years ago

Ran into the same issue trying to upgrade Nx v9.2.4 -> v9.3.0. Had to install @nrwl/tao manually again npm i @nrwl/tao --save-dev.

vsavkin commented 4 years ago

Folks. I'm going to close this issue. @nrwl/tao has been added as a dependency to @nrwl/cli, so you should not have to install it manually. If you still having problems migrating, please open another issue. Thank you!

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.