nrwl / nx

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

Error Upgrading from 10.4.15 to 11.0.1: Running migration replace-ng-packagr-builder Invalid migration file in package: "@angular/cli" #6599

Closed cnd5041 closed 2 years ago

cnd5041 commented 3 years ago

Current Behavior

> nx migrate 11.0.1 > npm install > nx migrate --run-migrations=migrations.json Observe Error: Running migration replace-ng-packagr-builder Invalid migration file in package: "@angular/cli" When I remove the replace-ng-packagr-builder migration from migrations.json and re-run the command (after backing out the previous failed migration): Running migration add-declaration-map-compiler-option Invalid migration file in package: "@angular/cli"

Also, if I try to run the migration with a specific version, the same error occurs, e.g.: npx @nrwl/tao@11.0.1 migrate --run-migrations migrations.json

Here are two of the failing migrations:

{
      "version": "11.0.0-next.0",
      "factory": "./update-11/replace-ng-packagr-builder",
      "description": "Replace deprecated library builder '@angular-devkit/build-ng-packagr'.",
      "package": "@angular/cli",
      "name": "replace-ng-packagr-builder"
    },
    {
      "version": "11.0.0-next.2",
      "factory": "./update-11/add-declaration-map-compiler-option",
      "description": "Add 'declarationMap' compiler options for non production library builds.",
      "package": "@angular/cli",
      "name": "add-declaration-map-compiler-option"
    },

I think it will fail on any of the migrations with "package": "@angular/cli", because there are no folders along those paths in the @angular node_module folder.

Expected Behavior

Steps to Reproduce

Please, see current behavior.

Failure Logs

Running migration replace-ng-packagr-builder Invalid migration file in package: "@angular/cli" Invalid migration file in package: "@angular/cli"

Environment

 Node : 14.17.3
  OS   : win32 x64
  npm  : 6.14.13

  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 : Not Found
  @nrwl/express : Not Found
  @nrwl/jest : 11.0.1
  @nrwl/linter : 11.0.1
  @nrwl/nest : Not Found
  @nrwl/next : Not Found
  @nrwl/node : Not Found
  @nrwl/react : Not Found
  @nrwl/schematics : Not Found
  @nrwl/tao : 11.0.1
  @nrwl/web : Not Found
  @nrwl/workspace : 11.0.1
  typescript : 3.9.10

Here is my package.json, after the nx migration:

{
  "name": "license-the-world-ui",
  "version": "3.4.0",
  "license": "MIT",
  "scripts": {
    "ng": "nx",
    "postinstall": "node ./decorate-angular-cli.js && ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points",
    "nx": "nx",
    "start": "ng serve",
    "build": "ng build",
    "build:license-expert:test": "nx build --configuration=test --progress=false --output-path=dist/apps/license-expert/test license-expert",
    "build:license-expert:beta": "nx build --configuration=beta --progress=false --output-path=dist/apps/license-expert/beta license-expert",
    "build:license-expert:prod": "nx build --configuration=production --progress=false --output-path=dist/apps/license-expert/prod license-expert",
    "build:admin:test": "nx build --configuration=test --progress=false --output-path=dist/apps/admin/test admin",
    "build:admin:beta": "nx build --configuration=beta --progress=false --output-path=dist/apps/admin/beta admin",
    "build:admin:prod": "nx build --configuration=production --progress=false --output-path=dist/apps/admin/prod admin",
    "test": "ng test",
    "lint": "nx workspace-lint && ng lint",
    "e2e": "ng e2e",
    "affected:apps": "nx affected:apps",
    "affected:libs": "nx affected:libs",
    "affected:build": "nx affected:build",
    "affected:e2e": "nx affected:e2e",
    "affected:test": "nx affected:test",
    "affected:lint": "nx affected:lint",
    "affected:dep-graph": "nx affected:dep-graph",
    "affected": "nx affected",
    "format": "nx format:write",
    "format:write": "nx format:write",
    "format:check": "nx format:check",
    "update": "ng update @nrwl/workspace",
    "workspace-schematic": "nx workspace-schematic",
    "dep-graph": "nx dep-graph",
    "help": "nx help"
  },
  "private": true,
  "jestSonar": {
    "reportPath": "reports",
    "reportFile": "ut_report.xml",
    "indent": 4
  },
  "dependencies": {
    "@angular/animations": "11.0.3",
    "@angular/cdk": "^10.1.3",
    "@angular/common": "11.0.3",
    "@angular/compiler": "11.0.3",
    "@angular/core": "11.0.3",
    "@angular/flex-layout": "^10.0.0-beta.32",
    "@angular/forms": "11.0.3",
    "@angular/material": "^10.1.3",
    "@angular/material-moment-adapter": "^10.1.3",
    "@angular/platform-browser": "11.0.3",
    "@angular/platform-browser-dynamic": "11.0.3",
    "@angular/router": "11.0.3",
    "@auth0/auth0-spa-js": "^1.11.0",
    "@material/snackbar": "^7.0.0",
    "@ng-dynamic-forms/core": "^12.0.0",
    "@ng-dynamic-forms/ui-material": "^12.0.0",
    "@ng-in-the-d/ngrx-auth0": "^0.2.0",
    "@ngrx/effects": "10.0.0",
    "@ngrx/entity": "10.0.0",
    "@ngrx/router-store": "10.0.0",
    "@ngrx/store": "10.0.0",
    "@ngrx/store-devtools": "10.0.0",
    "@ngx-translate/core": "^13.0.0",
    "@nrwl/angular": "11.0.1",
    "@swimlane/dragula": "^3.8.0",
    "@swimlane/ngx-charts": "^14.0.0",
    "@swimlane/ngx-datatable": "^17.1.0",
    "@swimlane/ngx-dnd": "^8.2.0",
    "@types/prismjs": "^1.16.1",
    "angular-calendar": "^0.28.16",
    "angular2-text-mask": "^9.0.0",
    "chart.js": "^2.9.3",
    "classlist.js": "^1.1.20150312",
    "core-js": "^3.6.5",
    "d3": "^5.16.0",
    "date-fns": "^2.16.0",
    "file-saver": "^2.0.5",
    "http-status-codes": "^1.4.0",
    "lodash": "^4.17.20",
    "moment": "^2.27.0",
    "ng2-charts": "^2.4.0",
    "ngrx": "0.0.1-security",
    "ngx-color-picker": "^9.1.0",
    "ngx-cookie-service": "^10.0.1",
    "ngx-mask": "^9.1.4",
    "ngx-spinner": "^9.0.2",
    "perfect-scrollbar": "^1.5.0",
    "prismjs": "^1.21.0",
    "rxjs": "6.5.5",
    "subsink": "^1.0.1",
    "text-mask-addons": "^3.8.0",
    "tslib": "^2.0.1",
    "web-animations-js": "^2.3.2",
    "zone.js": "^0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "0.1100.7",
    "@angular/cli": "11.0.7",
    "@angular/compiler-cli": "11.0.3",
    "@angular/language-service": "11.0.3",
    "@ngrx/schematics": "10.0.0",
    "@nrwl/cypress": "11.0.1",
    "@nrwl/jest": "11.0.1",
    "@nrwl/workspace": "11.0.1",
    "@types/jest": "26.0.8",
    "@types/node": "12.12.38",
    "codelyzer": "6.0.0",
    "cypress": "^4.12.1",
    "dotenv": "6.2.0",
    "eslint": "6.8.0",
    "jest": "26.2.2",
    "jest-marbles": "^2.5.1",
    "jest-preset-angular": "8.3.1",
    "jest-sonar-reporter": "^2.0.0",
    "prettier": "2.0.4",
    "sonar-scanner": "^3.1.0",
    "ts-jest": "26.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~6.0.0",
    "typescript": "^3.9.7"
  }
}

Full migration file:

{
  "migrations": [
    {
      "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-next.0",
      "factory": "./update-11/replace-ng-packagr-builder",
      "description": "Replace deprecated library builder '@angular-devkit/build-ng-packagr'.",
      "package": "@angular/cli",
      "name": "replace-ng-packagr-builder"
    },
    {
      "version": "11.0.0-next.2",
      "factory": "./update-11/add-declaration-map-compiler-option",
      "description": "Add 'declarationMap' compiler options for non production library builds.",
      "package": "@angular/cli",
      "name": "add-declaration-map-compiler-option"
    },
    {
      "version": "11.0.0-next.8",
      "factory": "./update-11/update-angular-config",
      "description": "Remove deprecated options from 'angular.json' that are no longer present in v11.",
      "package": "@angular/cli",
      "name": "update-angular-config-v11"
    },
    {
      "version": "11.0.0",
      "factory": "./update-11/update-dependencies",
      "description": "Update workspace dependencies to match a new v11 project.",
      "package": "@angular/cli",
      "name": "update-workspace-dependencies-v11"
    },
    {
      "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"
    }
  ]
}
Coly010 commented 3 years ago

Hi @cnd5041 !

Can you try this again with the latest version of Nx and report back if you have the same issue?

cnd5041 commented 3 years ago

@Coly010 are there steps I can take to make sure I am utilizing the latest version of Nx?

I re-installed globally npm install -g nx. My understanding, based on this post: https://github.com/nrwl/nx/issues/4333. Is that I shouldn't have to do anything to be running the latest version?

I did re-run. I observed the same error/behavior.

Coly010 commented 3 years ago

@cnd5041 If you run nx migrate latest, it should upgrade your workspace to the latest Nx versions. Then you'll want to try run nx migrate --run-migrations=migrations.json again.

If you could try that, it would be very helpful!

cnd5041 commented 3 years ago

@Coly010 I just ran those commands and migrations (npm installed in between). I got an error that I'll try to figure out a bit, but here is some info. Thank you for the help.

This is the error output:

>  NX  Running migrations from 'migrations.json'

Running migration update-decorate-angular-cli
Successfully finished update-decorate-angular-cli
---------------------------------------------------------
Running migration update-node-types
Successfully finished update-node-types
---------------------------------------------------------
Running migration rename-workspace-schematics
dest already exists.
C:\Code\web-ui\node_modules\@nrwl\workspace\node_modules\yargs\build\lib\yargs.js:1132
                throw err;

Migrations File:

{
  "migrations": [
    {
      "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": "11.0.0",
      "description": "Check that the right update command is used",
      "factory": "./src/migrations/update-11-0-0/update-command-check",
      "package": "@nrwl/workspace",
      "name": "update-command-check"
    },
    {
      "version": "11.0.2",
      "description": "Rename the workspace-schematic script into workspace-generator script",
      "factory": "./src/migrations/update-11-0-0/rename-workspace-schematic-script",
      "package": "@nrwl/workspace",
      "name": "rename-workspace-schematic-script"
    },
    {
      "version": "12.5.0-beta.1",
      "description": "Rename the workspace-schematic script into workspace-generator script",
      "factory": "./src/migrations/update-12-5-0/add-target-dependencies",
      "cli": "nx",
      "package": "@nrwl/workspace",
      "name": "add-target-dependencies"
    },
    {
      "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": "12.0.0-beta.0",
      "description": "adjusts the ngcc postinstall command to just leave 'ngcc' in there. This fixes Ivy in Jest tests and Storybooks",
      "factory": "./src/migrations/update-12-0-0/update-ngcc-postinstall",
      "package": "@nrwl/angular",
      "name": "update-ngcc-postinstall"
    },
    {
      "cli": "nx",
      "version": "12.3.1",
      "description": "Remove deprecated options and update others according to new defaults. It syncs with the v12 migration of Angular builders.",
      "factory": "./src/migrations/update-12-3-0/update-webpack-browser-config",
      "package": "@nrwl/angular",
      "name": "update-webpack-browser-config"
    },
    {
      "cli": "nx",
      "version": "12.3.1",
      "description": "Updates storybook configurations to support webpack 5",
      "factory": "./src/migrations/update-12-3-0/update-storybook",
      "package": "@nrwl/angular",
      "name": "update-storybook"
    },
    {
      "cli": "nx",
      "version": "12.3.1",
      "description": "Migrates some rules that have changed in Angular EsLint",
      "factory": "./src/migrations/update-12-3-0/update-angular-eslint-rules",
      "package": "@nrwl/angular",
      "name": "update-angular-eslint-rules"
    },
    {
      "cli": "nx",
      "version": "12.3.5-beta.0",
      "description": "Convert targets using @nrwl/angular:webpack-browser with the buildTarget option set to use the @nrwl/angular:delegate-build executor instead.",
      "factory": "./src/migrations/update-12-3-0/convert-webpack-browser-build-target-to-delegate-build",
      "package": "@nrwl/angular",
      "name": "convert-webpack-browser-build-target-to-delegate-build"
    },
    {
      "cli": "nx",
      "version": "12.9.0",
      "description": "Fixes invalid importPaths for buildable and publishable libs.",
      "factory": "./src/migrations/update-12-9-0/update-invalid-import-paths",
      "package": "@nrwl/angular",
      "name": "update-invalid-import-paths"
    },
    {
      "version": "11.0.0-next.0",
      "factory": "./update-11/replace-ng-packagr-builder",
      "description": "Replace deprecated library builder '@angular-devkit/build-ng-packagr'.",
      "package": "@angular/cli",
      "name": "replace-ng-packagr-builder"
    },
    {
      "version": "11.0.0-next.2",
      "factory": "./update-11/add-declaration-map-compiler-option",
      "description": "Add 'declarationMap' compiler options for non production library builds.",
      "package": "@angular/cli",
      "name": "add-declaration-map-compiler-option"
    },
    {
      "version": "11.0.0-next.8",
      "factory": "./update-11/update-angular-config",
      "description": "Remove deprecated options from 'angular.json' that are no longer present in v11.",
      "package": "@angular/cli",
      "name": "update-angular-config-v11"
    },
    {
      "version": "11.0.0",
      "factory": "./update-11/update-dependencies",
      "description": "Update workspace dependencies to match a new v11 project.",
      "package": "@angular/cli",
      "name": "update-workspace-dependencies-v11"
    },
    {
      "version": "12.0.0-next.0",
      "factory": "./update-12/update-angular-config",
      "description": "Remove deprecated options from 'angular.json' that are no longer present in v12.",
      "package": "@angular/cli",
      "name": "update-angular-config-v12"
    },
    {
      "version": "12.0.0-next.1",
      "factory": "./update-12/update-zonejs",
      "description": "Update 'zone.js' to version 0.11.x. Read more about this here: https://github.com/angular/angular/blob/master/packages/zone.js/CHANGELOG.md#breaking-changes-since-zonejs-v0111",
      "package": "@angular/cli",
      "name": "update-zonejs"
    },
    {
      "version": "12.0.0-next.2",
      "factory": "./update-12/remove-emit-decorator-metadata",
      "description": "Remove 'emitDecoratorMetadata' TypeScript compiler option. Decorator metadata is no longer needed by Angular. Read more about this here: https://www.typescriptlang.org/docs/handbook/decorators.html#metadata",
      "package": "@angular/cli",
      "name": "remove-emit-decorator-metadata"
    },
    {
      "version": "12.0.0-next.4",
      "factory": "./update-12/update-lazy-module-paths",
      "description": "Lazy loading syntax migration. Update lazy loading string syntax to use dynamic imports.",
      "package": "@angular/cli",
      "name": "lazy-loading-string-syntax"
    },
    {
      "version": "12.0.0-next.7",
      "factory": "./update-9/update-i18n#updateI18nConfig",
      "description": "Remove deprecated ViewEngine-based i18n build and extract options. Options present in the configuration will be converted to use non-deprecated options.",
      "package": "@angular/cli",
      "name": "remove-deprecated-i18n-options"
    },
    {
      "version": "12.0.0-next.7",
      "factory": "./update-12/update-web-workers",
      "description": "Updates Web Worker consumer usage to use the new syntax supported directly by Webpack 5.",
      "package": "@angular/cli",
      "name": "update-web-workers-webpack-5"
    },
    {
      "version": "12.0.1",
      "factory": "./update-12/schematic-options",
      "description": "Remove invalid 'skipTests' option in '@schematics/angular:module' Angular schematic options.",
      "package": "@angular/cli",
      "name": "schematic-options-12"
    },
    {
      "version": "12.1.0",
      "factory": "./update-12/replace-prod-flag",
      "description": "Replace the deprecated '--prod' in package.json scripts.",
      "package": "@angular/cli",
      "name": "replace-deprecated-prod-flag"
    },
    {
      "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"
    },
    {
      "version": "11.1.0-beta",
      "description": "Removes `canActivate` from a `Route` config when `redirectTo` is also present",
      "factory": "./migrations/can-activate-with-redirect-to/index",
      "package": "@angular/core",
      "name": "migration-v11.1-can-activate-with-redirect-to"
    },
    {
      "version": "12.0.0-beta",
      "description": "In Angular version 12, the type of ActivatedRouteSnapshot.fragment is nullable. This migration automatically adds non-null assertions to it.",
      "factory": "./migrations/activated-route-snapshot-fragment/index",
      "package": "@angular/core",
      "name": "migration-v12-activated-route-snapshot-fragment"
    },
    {
      "version": "12.0.0-next.6",
      "description": "`XhrFactory` has been moved from `@angular/common/http` to `@angular/common`.",
      "factory": "./migrations/xhr-factory/index",
      "package": "@angular/core",
      "name": "migration-v12-xhr-factory"
    },
    {
      "version": "12.0.2",
      "description": "Automatically migrates shadow-piercing selector from `/deep/` to the recommended alternative `::ng-deep`.",
      "factory": "./migrations/deep-shadow-piercing-selector/index",
      "package": "@angular/core",
      "name": "migration-v12-deep-shadow-piercing-selector"
    },
    {
      "version": "11.0.0-0",
      "description": "Updates Angular Material to v11",
      "factory": "./ng-update/index#updateToV11",
      "package": "@angular/material",
      "name": "migration-v11"
    },
    {
      "version": "12.0.0-0",
      "description": "Updates Angular Material to v12",
      "factory": "./ng-update/index#updateToV12",
      "package": "@angular/material",
      "name": "migration-v12"
    },
    {
      "cli": "nx",
      "version": "12.8.0-beta.0",
      "description": "Remove Typescript Preprocessor Plugin",
      "factory": "./src/migrations/update-12-8-0/remove-typescript-plugin",
      "package": "@nrwl/cypress",
      "name": "remove-typescript-plugin"
    },
    {
      "version": "12.1.0-beta.1",
      "cli": "nx",
      "description": "Update jest-preset-angular to version 8.4.0",
      "factory": "./src/migrations/update-12-1-2/update-jest-preset-angular",
      "package": "@nrwl/jest",
      "name": "update-jest-preset-angular-8-4-0"
    },
    {
      "version": "12.1.2-beta.1",
      "cli": "nx",
      "description": "Replace tsConfig with tsconfig for ts-jest in jest.config.js",
      "factory": "./src/migrations/update-12-1-2/update-ts-jest",
      "package": "@nrwl/jest",
      "name": "update-ts-jest-6-5-5"
    },
    {
      "version": "12.4.0-beta.1",
      "cli": "nx",
      "description": "Add testEnvironment: 'jsdom' in web apps + libraries",
      "factory": "./src/migrations/update-12-4-0/add-test-environment-for-node",
      "package": "@nrwl/jest",
      "name": "support-jest-27"
    },
    {
      "version": "12.4.0-beta.1",
      "cli": "nx",
      "description": "Support for Jest 27 via updating ts-jest + jest-preset-angular",
      "factory": "./src/migrations/update-12-4-0/update-jest-preset-angular",
      "package": "@nrwl/jest",
      "name": "update-ts-jest-and-jest-preset-angular"
    },
    {
      "version": "12.6.0-beta.0",
      "cli": "nx",
      "description": "Uses `getJestProjects()` to populate projects array in root level `jest.config.js` file.",
      "factory": "./src/migrations/update-12-6-0/update-base-jest-config",
      "package": "@nrwl/jest",
      "name": "update-jest-config-to-use-util"
    }
  ]
}
cnd5041 commented 3 years ago

Just for good measure, I deleted my node_modules and package lock. Redid the npm install and the migrations run. Same error output.

Update: I deleted the tools/schematics folder that was in the repo (it was empty). That seems to have fixed that problem.

Now getting:

Running migration convert-webpack-browser-build-target-to-delegate-build
Successfully finished convert-webpack-browser-build-target-to-delegate-build
---------------------------------------------------------
Running migration update-invalid-import-paths
Cannot find tsconfig.base.json
C:\Code\web-ui\node_modules\@nrwl\workspace\node_modules\yargs\build\lib\yargs.js:1132
                throw err;

Looking into this one now...

cnd5041 commented 3 years ago

Another update: I updated the global angular cli, re-ran the migrations, got the same error. I then manually changed the tsconfig.json to tsconfig.base.json. That got me down to migration-v11:

Error:

Running migration migration-v11
Cannot find module '@schematics/angular/utility/config'
Require stack:
- C:\Code\web-ui\node_modules\@angular\cdk\schematics\utils\ast.js
- C:\Code\web-ui\node_modules\@angular\cdk\schematics\utils\index.js
- C:\Code\web-ui\node_modules\@angular\cdk\schematics\index.js
- C:\Code\web-ui\node_modules\@angular\material\schematics\ng-update\index.js
- C:\Users\cnd\AppData\Local\Temp\tmp-9956-xG61oiEk1ZxU\node_modules\@angular-devkit\schematics\tools\export-ref.js
- C:\Users\cnd\AppData\Local\Temp\tmp-9956-xG61oiEk1ZxU\node_modules\@angular-devkit\schematics\tools\index.js
- C:\Users\cnd\AppData\Local\Temp\tmp-9956-xG61oiEk1ZxU\node_modules\@nrwl\tao\src\commands\ngcli-adapter.js
- C:\Users\cnd\AppData\Local\Temp\tmp-9956-xG61oiEk1ZxU\node_modules\@nrwl\tao\src\commands\migrate.js
- C:\Users\cnd\AppData\Local\Temp\tmp-9956-xG61oiEk1ZxU\node_modules\@nrwl\tao\index.js
C:\Code\web-ui\node_modules\@nrwl\workspace\node_modules\yargs\build\lib\yargs.js:1132
                throw err;
                ^

Error: Command failed: C:\Users\cnd\AppData\Local\Temp\tmp-9956-xG61oiEk1ZxU\node_modules\.bin\tao migrate --run-migrations=migrations.json
    at checkExecSyncError (child_process.js:643:11)
    at Object.execSync (child_process.js:679:15)
    at Object.handler (C:\Code\web-ui\node_modules\@nrwl\workspace\src\command-line\nx-commands.js:97:25)
    at Object.runCommand (C:\Code\web-ui\node_modules\@nrwl\workspace\node_modules\yargs\build\lib\command.js:196:48)
    at Object.parseArgs [as _parseArgs] (C:\Code\web-ui\node_modules\@nrwl\workspace\node_modules\yargs\build\lib\yargs.js:1043:55)
    at Object.get [as argv] (C:\Code\web-ui\node_modules\@nrwl\workspace\node_modules\yargs\build\lib\yargs.js:986:25)
    at Object.initLocal (C:\Code\web-ui\node_modules\@nrwl\cli\lib\init-local.js:24:13)
    at Object.<anonymous> (C:\Code\web-ui\node_modules\@nrwl\cli\bin\nx.js:40:18)
    at Module._compile (C:\.npm-global\node_modules\@nrwl\cli\node_modules\v8-compile-cache\v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10) {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 25032,
  stdout: null,
  stderr: null
}
Coly010 commented 3 years ago

@cnd5041 hi! migration-v11 seems to be a migration created by the @angular/material team.

Are you able to share the repo that contains this problem, or would you be able to recreate this issue in a minimal repo and share that with me?

Without being able to see the how the workspace is set up it'll be difficult to reproduce this issue to get to the bottom of it.

cnd5041 commented 3 years ago

@Coly010 unfortunately, it is a private repo, so I can't share. I will attempt to recreate when I get a free moment, hopefully this week. Thanks again.

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏

dretsa commented 1 year ago

I have been having the same issue and it seems like it's an out-of-sync issue.

The migration files you are looking for are in the @schematics/angular node package. Ensure you are using ^11 - you might need to manually upgrade this using your package manager.

Then you will still get the same error due to Nx looking for the files in the wrong folder.

I was upgrading from Nx 10.4.15. My steps to resolve this were:

  1. Run nx migrate 11.0.1 - generates migrations.json

  2. Update packages yarn/npm i/etc.

  3. Run migrations with yarn nx migrate --run-migrations=migrations.json. Wait for the replace-ng-packagr-builder migration to fail

  4. Delete all successfully ran migration from migrations.json

  5. Ensure @schematics/angular is installed and ^11

  6. Go to node_modules/@angular/cli/package.json and edit the ng-update.migrations key by prefixing it with ../../ so it looks in the correct place.

    {
    "migrations": "../../@schematics/angular/migrations/migration-collection.json",
    "packageGroup": "..."
    }
  7. Run yarn nx migrate --run-migrations=migrations.json again

  8. Great success (Reference)

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.