nx: Running migration update-angular-config-v12 results in Cannot read property 'startsWith' of undefined

Current Behavior

Running migration update-angular-config-v12 results in Cannot read property 'startsWith' of undefined

Expected Behavior

migration succeeds

Steps to Reproduce

yarn nx migrate latest yarn yarn nx migrate --run-migrations

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

Failure Logs

NX Running migrations from ‘migrations.json’

Running migration update-webpack-browser-config
Successfully finished update-webpack-browser-config
---------------------------------------------------------
Running migration update-storybook
Successfully finished update-storybook
---------------------------------------------------------
Running migration update-angular-eslint-rules
Successfully finished update-angular-eslint-rules
---------------------------------------------------------
Running migration update-angular-config-v12
Cannot read property 'startsWith' of undefined
/repo/node_modules/yargs/build/lib/yargs.js:1132
                throw err;
                ^

Error: Command failed: /var/folders/cv/ryn9x0td5jd5dcmv6l2v8qn80000gn/T/tmp-7617-kbvcwfaGiqNx/node_modules/.bin/tao migrate --run-migrations
    at checkExecSyncError (child_process.js:635:11)
    at Object.execSync (child_process.js:671:15)
    at Object.handler (/repo/node_modules/@nrwl/workspace/src/command-line/nx-commands.js:90:25)
    at Object.runCommand (/repo/node_modules/yargs/build/lib/command.js:196:48)
    at Object.parseArgs [as _parseArgs] (/repo/node_modules/yargs/build/lib/yargs.js:1043:55)
    at Object.get [as argv] (/repo/node_modules/yargs/build/lib/yargs.js:986:25)
    at Object.initLocal (/repo/node_modules/@nrwl/cli/lib/init-local.js:26:79)
    at Object.<anonymous> (/repo/node_modules/@nrwl/cli/bin/nx.js:43:18)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10) {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 7701,
  stdout: null,
  stderr: null
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Environment


>  NX  Report complete - copy this into the issue template

  Node : 12.20.1
  OS   : darwin x64
  yarn : 1.22.10
  
  nx : Not Found
  @nrwl/angular : 12.3.1
  @nrwl/cli : 12.3.1
  @nrwl/cypress : 12.3.1
  @nrwl/devkit : 12.3.1
  @nrwl/eslint-plugin-nx : 12.3.1
  @nrwl/express : 12.3.1
  @nrwl/jest : 12.3.1
  @nrwl/linter : 12.3.1
  @nrwl/nest : 12.3.1
  @nrwl/next : Not Found
  @nrwl/node : 12.3.1
  @nrwl/react : Not Found
  @nrwl/schematics : Not Found
  @nrwl/tao : 12.3.1
  @nrwl/web : 12.3.1
  @nrwl/workspace : 12.3.1
  @nrwl/storybook : 12.3.1
  @nrwl/gatsby : Not Found
  typescript : 4.2.4

✨  Done in 0.85s.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 3
  • Comments: 40 (20 by maintainers)

Most upvoted comments

For anyone arriving at this issue, please check your workspace config and make sure all your targets have a builder specified.

I’m closing this one since it’s not an Nx issue and a solution has been found. Please feel free to reopen it if the provided solution doesn’t work.

for build: “builder”: “@angular-builders/custom-webpack:browser” for serve: “builder”: “ngx-build-plus:dev-server”,

Angular 12 now needs Webpack 5. Those custom builders are still on Webpack 4 and don’t support Webpack 5. You’d need to wait for them to support it. In the repo for the @angular-builders/custom-webpack there is this issue you can follow https://github.com/just-jeb/angular-builders/issues/972.

also getting a wired warning: “BuildCustomWebpackBrowserSchema” schema is using the keyword “id” which its support is deprecated. Use “$id” for schema ID.

In Angular 12 there is a breaking change where schemas are validated against the JSON Schema Draft-07. There is nothing for you to do here, but the above custom builders need to update their schema to meet the specs.

also getting a wired warning: “BuildCustomWebpackBrowserSchema” schema is using the keyword “id” which its support is deprecated. Use “$id” for schema ID.

@leosvelperez I think another repo out there with similar issue (& proxy fix) threw me off on a wrong path. And you are right that a target is missing a builder and the issue is from the following line in ng upgrade … Thx.

 // update-angular-config.js
 for (const [, target] of workspace_1.allWorkspaceTargets(workspace)) {
   if (!(target === null || target === void 0 ? void 0 : target.builder.startsWith('@angular-devkit/build-angular'))) {
      continue;
   }
   // ...
 }

I hope someday angular publishes a ng check angular.json command so people can find out what is going on exactly.