nx: Cannot convert undefined or null to object

Current Behavior

I am currently on 12.10.0 version. When I run nx migrate @nrwl/workspace@13.1.4 --verbose command I am getting an error.

package.json

“dependencies”: { “@angular/animations”: “^12.2.0”, “@angular/cdk”: “^12.2.0”, “@angular/common”: “^12.2.0”, “@angular/compiler”: “^12.2.0”, “@angular/core”: “^12.2.0”, “@angular/forms”: “^12.2.0”, “@angular/localize”: “^12.2.9”, “@angular/platform-browser”: “^12.2.0”, “@angular/platform-browser-dynamic”: “^12.2.0”, “@angular/router”: “^12.2.0”, “@nrwl/angular”: “^12.10.1”, “fs-extra”: “^10.0.0”, “http-status-codes”: “^2.1.4”, “keycloak-angular”: “^7.3.1”, “keycloak-js”: “^9.0.3”, “lodash.sortby”: “^4.7.0”, “minimist”: “^1.2.5”, “moment”: “^2.24.0”, “moment-timezone”: “^0.5.27”, “ngx-hotjar”: “0.0.5”, “node-fetch”: “^2.6.1”, “primeng”: “^9.1.0”, “rxjs”: “^6.5.4”, “tslib”: “^2.0.0”, “uuid”: “^8.3.2”, “zone.js”: “~0.11.4” }, “devDependencies”: { “@angular-devkit/build-angular”: “12.2.15”, “@angular-eslint/eslint-plugin”: “~12.3.0”, “@angular-eslint/eslint-plugin-template”: “~12.3.0”, “@angular-eslint/template-parser”: “~12.3.0”, “@angular/cli”: “12.2.15”, “@angular/compiler-cli”: “12.2.0”, “@angular/language-service”: “12.2.0”, “@nrwl/cli”: “^12.10.1”, “@nrwl/cypress”: “^12.10.1”, “@nrwl/eslint-plugin-nx”: “^12.10.1”, “@nrwl/jest”: “^12.10.1”, “@nrwl/linter”: “^12.10.1”, “@nrwl/tao”: “^12.10.1”, “@nrwl/workspace”: “^12.10.1”, “@types/jest”: “27.0.2”, “@types/node”: “14.14.33”, “@typescript-eslint/eslint-plugin”: “4.31.2”, “@typescript-eslint/parser”: “4.31.2”, “cypress”: “^9.5.1”, “cypress-grep”: “^2.10.1”, “cypress-keycloak-commands”: “^1.2.0”, “cypress-multi-reporters”: “^1.6.0”, “eslint”: “7.32.0”, “eslint-config-prettier”: “8.1.0”, “eslint-plugin-cypress”: “^2.10.3”, “husky”: “^7.0.4”, “jest”: “27.2.3”, “jest-junit”: “^13.0.0”, “jest-preset-angular”: “10.0.1”, “json-server”: “^0.16.1”, “lint-staged”: “^12.1.2”, “mocha”: “^9.2.2”, “mocha-junit-reporter”: “^2.0.2”, “ng-mocks”: “^10.1.2”, “ng-packagr”: “^9.0.0”, “npm”: “~6.14.16”, “postcss”: “^8.3.9”, “postcss-import”: “^14.0.2”, “postcss-preset-env”: “^6.7.0”, “postcss-url”: “^10.1.1”, “prettier”: “^2.3.1”, “sonar-scanner”: “^3.1.0”, “ts-jest”: “27.0.5”, “typescript”: “4.3.5” }

ERROR The migrate command failed.

Cannot convert undefined or null to object TypeError: Cannot convert undefined or null to object at Function.values (<anonymous>) at C:\Users\AppData\Local\Temp\tmp-161692-6Qql83Kb3MgY\node_modules\nx\src\command-line\connect-to-nx-cloud.js:38:36 at Generator.next (<anonymous>) at C:\Users\AppData\Local\Temp\tmp-161692-6Qql83Kb3MgY\node_modules\nx\node_modules\tslib\tslib.js:118:75 at new Promise (<anonymous>) at Object.__awaiter (C:\Users\AppData\Local\Temp\tmp-161692-6Qql83Kb3MgY\node_modules\nx\node_modules\tslib\tslib.js:114:16) at connectToNxCloudCommand (C:\Users\AppData\Local\Temp\tmp-161692-6Qql83Kb3MgY\node_modules\nx\src\command-line\connect-to-nx-cloud.js:36:20) at C:\Users\AppData\Local\Temp\tmp-161692-6Qql83Kb3MgY\node_modules\nx\src\command-line\migrate.js:560:73 at Generator.next (<anonymous>) at fulfilled (C:\Users\AppData\Local\Temp\tmp-161692-6Qql83Kb3MgY\node_modules\nx\node_modules\tslib\tslib.js:115:62)

Expected Behavior

Expect the migration to the newer version work as expected.

Steps to Reproduce

This issue may not be prioritized if details are not provided to help us reproduce the issue.

Failure Logs

Environment

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 19 (5 by maintainers)

Most upvoted comments

Getting the same on the latest NX release. No command is working any longer.

TypeError: Cannot convert undefined or null to object
    at Function.values (<anonymous>)
    at workspaceConfigurationCheck (/Users/marvin/Developer/entergon/app/node_modules/.pnpm/nx@15.8.1/node_modules/nx/src/utils/workspace-configuration-check.js:23:32)
    at Object.<anonymous> (/Users/marvin/Developer/entergon/app/node_modules/.pnpm/nx@15.8.1/node_modules/nx/src/command-line/run-one.js:19:73)
    at Generator.next (<anonymous>)
    at /Users/marvin/Developer/entergon/app/node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.js:167:75
    at new Promise (<anonymous>)
    at Object.__awaiter (/Users/marvin/Developer/entergon/app/node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.js:163:16)
    at Object.runOne (/Users/marvin/Developer/entergon/app/node_modules/.pnpm/nx@15.8.1/node_modules/nx/src/command-line/run-one.js:16:20)
    at /Users/marvin/Developer/entergon/app/node_modules/.pnpm/nx@15.8.1/node_modules/nx/src/command-line/nx-commands.js:51:147
    at Generator.next (<anonymous>)

I’m facing the same issue with nx g @nrwl/storybook:configuration

same issue with npx nx init

Ok, my issue came from using angular.json so I can ng update on my libs. Adding an empty projects prop fixed it.

I have no idea other than to try {} instead of all of the stuff I put in. ie. tasksRunnerOptions: {}… or figure out what that default task runner is, and how to install it.

I had the same error using 12.10.0. This is the line that it is failing on:

const nxCloudUsed = Object.values(nxJson.tasksRunnerOptions).find((r) => r.runner == '@nrwl/nx-cloud');

I took a look at my nx.json file, and it didn’t have a taskRunnerOptions setting in it. I created a brand new workspace and copied what was in there and was able to get past this error.

This is what I added to my nx.json

"tasksRunnerOptions": {
    "default": {
      "runner": "nx/tasks-runners/default",
      "options": {
        "cacheableOperations": ["build", "lint", "test", "e2e"]
      }
    }
  },