angularmigrationpackage.jsontsconfignx-monorepo

Inject migration angular didn't work on nx workspace


I use this nx generate @angular/core:inject to migrate projects but get below error:

Could not find any files to migrate under the path /home/jibit/Desktop/jibit-angular-workspace/. Cannot run the inject migration.

enter image description here

also try to use --path to address specific project in apps folder.

I can't figure out this problem is related to what? tsconfig maybe? or mismatch package versions?

Tsconfig:

{
 "compileOnSave": false,
 "compilerOptions": {
 "moduleResolution": "bundler",
 "experimentalDecorators": true,
 "importHelpers": true,
 "target": "ES2022",
 "module": "ES2022",
 "skipLibCheck": true,
 "baseUrl": ".",
 "outDir": "./dist/out-tsc",
 "strict": false,
 "noImplicitOverride": false,
 "noPropertyAccessFromIndexSignature": false,
 "noImplicitReturns": false,
 "noFallthroughCasesInSwitch": true,
 "isolatedModules": false,
 "esModuleInterop": true,
 "paths": {
   "@Yavanna/*": ["./apps/yavanna/src/app/*"]
 }
},
 "angularCompilerOptions": {
 "enableI18nLegacyMessageIdFormat": false,
 "strictInjectionParameters": true,
 "strictInputAccessModifiers": true,
 "fullTemplateTypeCheck": true
 },
 "ts-node": {
  "compilerOptions": {
   "module": "commonjs",
   "moduleResolution": "node10"
  }
 }
}

package.json:

"dependencies": {
  "@angular/animations": "20.3.4",
  "@angular/cdk": "20.2.8",
  "@angular/common": "20.3.4",
  "@angular/compiler": "20.3.4",
  "@angular/core": "20.3.4",
  "@angular/forms": "20.3.4",
  "@angular/localize": "20.3.4",
  "@angular/material": "20.2.8",
  "@angular/platform-browser": "20.3.4",
  "@angular/platform-browser-dynamic": "20.3.4",
  "@angular/router": "20.3.4",
  "@ng-bootstrap/ng-bootstrap": "^19.0.1",
  "@ng-select/ng-select": "^20.3.0",
  "@popperjs/core": "^2.11.8",
  "@swimlane/ngx-charts": "^23.0.1",
  "angular-ng-autocomplete": "^2.0.12",
  "bootstrap": "^5.3.8",
  "caniuse-lite": "^1.0.30001750",
  "echarts": "^6.0.0",
  "file-saver": "^2.0.5",
  "highcharts": "^12.4.0",
  "highcharts-angular": "^5.1.0",
  "jalali-moment": "^3.3.11",
  "json-bigint": "^1.0.0",
  "ng-circle-progress": "^1.7.1",
  "ngx-clipboard": "^16.0.0",
  "ngx-cookie-service": "^20.1.0",
  "ngx-echarts": "^20.0.2",
  "ngx-json-viewer": "^3.2.1",
  "ngx-mask": "^17.0.4",
  "ngx-quill": "^28.0.1",
  "nxt-json-view": "^20.0.0",
  "quill": "^2.0.3",
  "rxjs": "~7.8.2",
  "tslib": "^2.8.1",
  "uuid": "^13.0.0",
  "vazirmatn": "^33.0.3",
  "xng-breadcrumb": "^14.1.0",
  "zone.js": "^0.15.0"
},
"devDependencies": {
  "@angular-devkit/build-angular": "^20.3.5",
  "@angular-devkit/core": "20.3.5",
  "@angular-devkit/schematics": "20.3.5",
  "@angular-eslint/builder": "20.4.0",
  "@angular-eslint/eslint-plugin": "20.4.0",
  "@angular-eslint/eslint-plugin-template": "20.4.0",
  "@angular-eslint/schematics": "20.4.0",
  "@angular-eslint/template-parser": "20.4.0",
  "@angular/build": "20.3.5",
  "@angular/cli": "~20.3.5",
  "@angular/compiler-cli": "20.3.4",
  "@angular/language-service": "20.3.4",
  "@compodoc/compodoc": "^1.1.31",
  "@eslint/js": "^9.37.0",
  "@nx/angular": "21.6.4",
  "@nx/devkit": "21.6.4",
  "@nx/eslint": "21.6.4",
  "@nx/eslint-plugin": "21.6.4",
  "@nx/jest": "21.6.4",
  "@nx/js": "21.6.4",
  "@nx/playwright": "21.6.4",
  "@nx/storybook": "21.6.4",
  "@nx/web": "21.6.4",
  "@nx/workspace": "21.6.4",
  "@playwright/test": "^1.56.0",
  "@schematics/angular": "20.3.5",
  "@storybook/addon-docs": "^9.1.10",
  "@storybook/addon-themes": "^9.1.10",
  "@storybook/angular": "9.1.10",
  "@storybook/test-runner": "^0.23.0",
  "@swc-node/register": "~1.11.1",
  "@swc/core": "~1.13.5",
  "@swc/helpers": "~0.5.17",
  "@types/google.analytics": "0.0.46",
  "@types/jasmine": "~5.1.9",
  "@types/jasminewd2": "~2.0.13",
  "@types/jest": "^30.0.0",
  "@types/node": "^24.7.2",
  "@typescript-eslint/eslint-plugin": "^8.46.0",
  "@typescript-eslint/parser": "^8.46.0",
  "@typescript-eslint/utils": "^8.46.0",
  "angular-eslint": "20.4.0",
  "barrelsby": "^2.8.1",
  "eslint": "^9.37.0",
  "eslint-config-prettier": "^10.1.8",
  "eslint-plugin-playwright": "^2.2.2",
  "eslint-plugin-storybook": "^9.1.10",
  "jest": "^29.7.0",
  "jest-environment-jsdom": "^29.7.0",
  "jest-preset-angular": "^14.6.1",
  "jest-util": "^29.7.0",
  "nx": "21.6.4",
  "prettier": "^3.6.2",
  "storybook": "9.1.10",
  "storybook-addon-rtl": "^2.0.0",
  "ts-jest": "^29.4.5",
  "ts-node": "~10.9.2",
  "tslib": "^2.8.1",
  "typescript": "5.9.2",
  "typescript-eslint": "^8.46.0"
}

Solution

  • I had the same issue when trying to run:

    nx generate @angular/core:inject
    

    and got:

    Could not find any files to migrate under the path ... Cannot run the inject migration.
    

    After a lot of debugging, the problem turned out not to be with NX or Angular directly, but with Jest test setup conflicting with the migration tooling.

    What fixed it for me

    I migrated from Jest → Vitest, and after that the inject migration started working normally.

    In my case tsconfig.spec.json changed from:

    "compilerOptions": {
      "outDir": "../../dist/out-tsc",
      "module": "commonjs",
      "target": "es2016",
      "types": ["jest", "node"],
      "moduleResolution": "node10"
    }
    

    to:

    "compilerOptions": {
      "outDir": "../../dist/out-tsc",
      "types": [
        "vitest/globals",
        "vitest/importMeta",
        "vite/client",
        "node",
        "vitest"
      ]
    }
    

    I can’t say with 100% certainty whether it was specifically the type definitions, the removal of old Jest configs, or package incompatibility, but switching to Vitest resolved it immediately and the migration executed successfully.