question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

nx migrate fails when updating the workspace to 11

See original GitHub issue

Current Behavior

I have a nx workspace with nx CLI. The workspace has angular projects and when I’m migrating it to the latest nx 11, it bumps the dependencies but the migration scripts fail and fail to update the angular 11 specific migrations.

Migration script that is generated:

{
	"migrations": [
		{
			"version": "10.4.5",
			"description": "Update the 'update' npm script to invoke nx migrate",
			"factory": "./src/migrations/update-10-4-0/update-script-to-invoke-nx-migrate",
			"package": "@nrwl/workspace",
			"name": "update-script-to-invoke-nx-migrate"
		},
		{
			"version": "11.0.0-beta.3",
			"description": "Update the decoration script when using Angular CLI",
			"factory": "./src/migrations/update-11-0-0/update-decorate-angular-cli",
			"package": "@nrwl/workspace",
			"name": "update-decorate-angular-cli"
		},
		{
			"version": "11.0.0-beta.3",
			"description": "Update the @types/node package",
			"factory": "./src/migrations/update-11-0-0/update-node-types",
			"package": "@nrwl/workspace",
			"name": "update-node-types"
		},
		{
			"version": "11.0.0-beta.3",
			"description": "Rename tools/schematics into tools/generators",
			"factory": "./src/migrations/update-11-0-0/rename-workspace-schematics",
			"package": "@nrwl/workspace",
			"name": "rename-workspace-schematics"
		},
		{
			"version": "11.0.0-beta.15",
			"description": "Adds `outputs` based on builders",
			"factory": "./src/migrations/update-11-0-0/add-outputs-in-workspace",
			"package": "@nrwl/workspace",
			"name": "add-outputs-in-workspace"
		},
		{
			"version": "10.5.0-beta.0",
			"description": "Update eslint config and builder to extend from new Nx Angular presets and lint templates",
			"factory": "./src/migrations/update-10-5-0/add-template-support-and-presets-to-eslint",
			"package": "@nrwl/angular",
			"name": "add-template-support-and-presets-to-eslint"
		},
		{
			"version": "11.0.0-beta.13",
			"description": "Update builder configurations and dependencies",
			"factory": "./src/migrations/update-11-0-0/update-builders-config",
			"package": "@nrwl/angular",
			"name": "update-11-0-0"
		},
		{
			"version": "11.0.0-beta",
			"description": "NavigationExtras omissions migration. In version 11, some unsupported properties were omitted from the `extras` parameter of the `Router.navigateByUrl` and `Router.createUrlTree` methods.",
			"factory": "./migrations/navigation-extras-omissions/index",
			"package": "@angular/core",
			"name": "migration-v11-navigation-extras-omissions"
		},
		{
			"version": "11.0.0-beta",
			"description": "The default value for `relativeLinkResolution` is changing from 'legacy' to 'corrected'.\nThis migration updates `RouterModule` configurations that use the default value to \nnow specifically use 'legacy' to prevent breakages when updating.",
			"factory": "./migrations/relative-link-resolution/index",
			"package": "@angular/core",
			"name": "migration-v11-router-relative-link-resolution-default"
		},
		{
			"version": "11.0.0-beta",
			"description": "In Angular version 11, the type of `AbstractControl.parent` can be `null` to reflect the runtime value more accurately. This migration automatically adds non-null assertions to existing accesses of the `parent` property on types like `FormControl`, `FormArray` and `FormGroup`.",
			"factory": "./migrations/abstract-control-parent/index",
			"package": "@angular/core",
			"name": "migration-v11-abstract-control-parent"
		},
		{
			"version": "11.0.0-beta",
			"description": "ViewEncapsulation.Native has been removed as of Angular version 11. This migration replaces any usages with ViewEncapsulation.ShadowDom.",
			"factory": "./migrations/native-view-encapsulation/index",
			"package": "@angular/core",
			"name": "migration-v11-native-view-encapsulation"
		},
		{
			"version": "11.0.0-beta",
			"description": "`async` to `waitForAsync` migration. The `async` testing function has been renamed to `waitForAsync` to avoid confusion with the native `async` keyword.",
			"factory": "./migrations/wait-for-async/index",
			"package": "@angular/core",
			"name": "migration-v11-wait-for-async"
		},
		{
			"version": "11.0.0-beta",
			"description": "NavigationExtras.preserveQueryParams has been removed as of Angular version 11.  This migration replaces any usages with the appropriate assignment of the queryParamsHandling key.",
			"factory": "./migrations/router-preserve-query-params/index",
			"package": "@angular/core",
			"name": "migration-v11-router-preserve-query-params"
		},
		{
			"version": "11.0.0-beta",
			"description": "Updates the `initialNavigation` property for `RouterModule.forRoot`.",
			"factory": "./migrations/initial-navigation/index",
			"package": "@angular/core",
			"name": "migration-v11-router-initial-navigation-options"
		}
	]
}

It fails to run all the angular specific migrations.

Expected Behavior

Should have successfully run all the update scripts in the migration.json

Steps to Reproduce

  1. Generate the workspace with version "@nrwl/workspace": "10.4.4"
  2. Select empty preset.
  3. Select Nx CLI as the default CLI.
  4. Run yarn add -D @nrwl/angular@10.4.4 .
  5. Generate the angular application with the command yarn nx generate @nrwl/angular:application --name=migration-app --style=scss --directory=client --linter=eslint --routing --strict --tags='scope: migration, type: app'
  6. Generate a couple of workspace angular libraries yarn nx generate @nrwl/angular:library --name=core --style=scss --linter=eslint --tags='scope: core, type: utils' and import them into the angular application.
  7. Run yarn run update.
  8. It will bump the dependencies and create the migration.json
  9. Run yarn nx migrate --run-migrations=migrations.json
  10. It will fail to update the angular specific migration with the message Could not find any tsconfig file. Cannot migrate away from Native view encapsulation.

The update scripts that fail

		{
			"version": "11.0.0-beta",
			"description": "NavigationExtras.preserveQueryParams has been removed as of Angular version 11.  This migration replaces any usages with the appropriate assignment of the queryParamsHandling key.",
			"factory": "./migrations/router-preserve-query-params/index",
			"package": "@angular/core",
			"name": "migration-v11-router-preserve-query-params"
		},
		{
			"version": "11.0.0-beta",
			"description": "Updates the `initialNavigation` property for `RouterModule.forRoot`.",
			"factory": "./migrations/initial-navigation/index",
			"package": "@angular/core",
			"name": "migration-v11-router-initial-navigation-options"
		}
		{
			"version": "11.0.0-beta",
			"description": "NavigationExtras omissions migration. In version 11, some unsupported properties were omitted from the `extras` parameter of the `Router.navigateByUrl` and `Router.createUrlTree` methods.",
			"factory": "./migrations/navigation-extras-omissions/index",
			"package": "@angular/core",
			"name": "migration-v11-navigation-extras-omissions"
		},
		{
			"version": "11.0.0-beta",
			"description": "The default value for `relativeLinkResolution` is changing from 'legacy' to 'corrected'.\nThis migration updates `RouterModule` configurations that use the default value to \nnow specifically use 'legacy' to prevent breakages when updating.",
			"factory": "./migrations/relative-link-resolution/index",
			"package": "@angular/core",
			"name": "migration-v11-router-relative-link-resolution-default"
		},
		{
			"version": "11.0.0-beta",
			"description": "In Angular version 11, the type of `AbstractControl.parent` can be `null` to reflect the runtime value more accurately. This migration automatically adds non-null assertions to existing accesses of the `parent` property on types like `FormControl`, `FormArray` and `FormGroup`.",
			"factory": "./migrations/abstract-control-parent/index",
			"package": "@angular/core",
			"name": "migration-v11-abstract-control-parent"
		},
		{
			"version": "11.0.0-beta",
			"description": "ViewEncapsulation.Native has been removed as of Angular version 11. This migration replaces any usages with ViewEncapsulation.ShadowDom.",
			"factory": "./migrations/native-view-encapsulation/index",
			"package": "@angular/core",
			"name": "migration-v11-native-view-encapsulation"
		},
		{
			"version": "11.0.0-beta",
			"description": "`async` to `waitForAsync` migration. The `async` testing function has been renamed to `waitForAsync` to avoid confusion with the native `async` keyword.",
			"factory": "./migrations/wait-for-async/index",
			"package": "@angular/core",
			"name": "migration-v11-wait-for-async"
		}

Minimal Github Repo for the issue https://github.com/navneetsharmaui/nx-migration-issue

Failure Logs

image

image

Environment

  Node : 12.14.1
  OS   : linux x64
  yarn : 1.22.5
  
  nx : Not Found
  @nrwl/angular : 11.0.1
  @nrwl/cli : 11.0.1
  @nrwl/cypress : 11.0.1
  @nrwl/devkit : 11.0.1
  @nrwl/eslint-plugin-nx : 11.0.1
  @nrwl/express : 11.0.1
  @nrwl/jest : 11.0.1
  @nrwl/linter : 11.0.1
  @nrwl/nest : 11.0.1
  @nrwl/next : Not Found
  @nrwl/node : 11.0.1
  @nrwl/react : Not Found
  @nrwl/schematics : Not Found
  @nrwl/tao : 11.0.1
  @nrwl/web : 11.0.1
  @nrwl/workspace : 11.0.1
  typescript : 4.0.5

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

5reactions
vsavkincommented, Dec 14, 2020

The issue is that the migration provided by the Angular framework looks at angular.json trying to resolve the tsconfig. In your case there is no angular.json. We normally work around this issue by telling the Angular CLI to also look at workspace.json. This wasn’t an option here.

We have a generic solution for this prepared and we are planning to land it by end of week. For now, the workaround is:

  • mv workspace.json angular.json
  • nx migrate --run-migrations=migrations.json
  • mv angular.json workspace.json

I know it’s annoying.

Does it make sense?

3reactions
vsavkincommented, Dec 16, 2020

Fixed the issue here: https://github.com/nrwl/nx/commit/4278cfd337bbee155ed5efba83c4edc3df58dd30 I’ll cut a patch release tonight.

I’m going to close this. If you have any issues upgrading after the release, let me know.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nx Upgrade from v11 to v12.10.1 is giving "Module not found ...
I am currently on Nx version 11 using Angular 11 in my project. I am trying to upgrade Nx to v12.10.1. I believe...
Read more >
migrate - CLI command - Nx
Creates a migrations file or runs migrations from the migrations file. Migrate packages and create migrations.json (e.g., nx migrate @nrwl/workspace@latest) ...
Read more >
Nx 14.2 — Angular v14, Storybook update, lightweight Nx and ...
Easy migration from Angular CLI to Nx. Nx is not only for large monorepos, but works really well for single-project Angular workspaces too!...
Read more >
The ultimate migration guide to angular-eslint, ESLint and Nx 11
When updating to Nx 11, workspaces using ESLint will be migrated to also use angular-eslint. Using NPM CLI: nx migrate @nrwl/workspace npm ...
Read more >
Migration from 10.4.5 to 11.0.1 fails · Issue #5932 · nrwl/nx
I am trying to migrate from 10.4.5 to 11.0.1 and it failed. ... src/migrations/update-11-0-0/rename-workspace-schematics", ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found