Closed cnd5041 closed 2 years ago
Hi @cnd5041 !
Can you try this again with the latest version of Nx and report back if you have the same issue?
@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.
@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!
@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"
}
]
}
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...
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
}
@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.
@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.
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! 🙏
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:
Run nx migrate 11.0.1
- generates migrations.json
Update packages yarn/npm i/etc.
Run migrations with yarn nx migrate --run-migrations=migrations.json
. Wait for the replace-ng-packagr-builder
migration to fail
Delete all successfully ran migration from migrations.json
Ensure @schematics/angular
is installed and ^11
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": "..."
}
Run yarn nx migrate --run-migrations=migrations.json
again
Great success (Reference)
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.
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 thereplace-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:
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
Here is my package.json, after the nx migration:
Full migration file: