question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"TypeError: Cannot read properties of undefined (reading 'endsWith')\n"

See original GitHub issue

Current Behavior

After updating to nx : 13.8.5 Running nx format:check throws error-

{
  stack: "TypeError: Cannot read properties of undefined (reading 'endsWith')\n" +
    '    at createProjectRootMappings (D:\\Inboxwidgets\\desk-ng\\node_modules\\@nrwl\\workspace\\src\\core\\file-map-utils.js:12:38)\n' +
    '    at createProjectFileMap (D:\\Inboxwidgets\\desk-ng\\node_modules\\@nrwl\\workspace\\src\\core\\file-map-utils.js:27:33)\n' +
    '    at D:\\Inboxwidgets\\desk-ng\\node_modules\\@nrwl\\workspace\\src\\core\\project-graph\\daemon\\server\\project-graph-incremental-recomputation.js:92:85\n' +
    '    at Generator.next (<anonymous>)\n' +
    '    at fulfilled (D:\\Inboxwidgets\\desk-ng\\node_modules\\tslib\\tslib.js:114:62)\n' +
    '    at processTicksAndRejections (node:internal/process/task_queues:96:5)',
  message: "Cannot read properties of undefined (reading 'endsWith')\n" +
    '\n' +
    'Because of the error the Nx daemon process has exited. The next Nx command is going to restart the daemon process.\n' +
    'If the error persists, please run "nx reset".'
}

Expected Behavior

Steps to Reproduce

run nx format:check OR run nx run-many --all --target=lint

Migration.json

{
  "migrations": [
    {
      "version": "13.0.0-beta.1",
      "description": "Add default base to nx.json if its not currently set",
      "factory": "./src/migrations/update-13-0-0/set-default-base-if-not-set",
      "cli": "nx",
      "package": "@nrwl/workspace",
      "name": "set-default-base-if-not-set"
    },
    {
      "version": "13.0.0-beta.4",
      "description": "Move global settings into nx.json, and project specific settings into workspace.json",
      "cli": "nx",
      "implementation": "./src/migrations/update-13-0-0/config-locations/config-locations",
      "package": "@nrwl/workspace",
      "name": "13-0-0-config-locations"
    },
    {
      "version": "13.2.0",
      "description": "Set --parallel=1 for existing repos to preserve the existing behavior",
      "cli": "nx",
      "implementation": "./src/migrations/update-13-2-0/set-parallel-default",
      "package": "@nrwl/workspace",
      "name": "set-parallel-default"
    },
    {
      "version": "13.3.0-beta.0",
      "description": "@nrwl/workspace:tsc is now @nrwl/js:tsc",
      "cli": "nx",
      "implementation": "./src/migrations/update-13-3-0/update-tsc-executor-location",
      "package": "@nrwl/workspace",
      "name": "13-3-0-tsc-location"
    },
    {
      "version": "13.6.0-beta.0",
      "description": "Remove old options that are no longer used",
      "cli": "nx",
      "implementation": "./src/migrations/update-13-6-0/remove-old-task-runner-options",
      "package": "@nrwl/workspace",
      "name": "13-6-0-remove-old-task-runner-options"
    },
    {
      "cli": "nx",
      "version": "13.0.0-beta.10",
      "description": "Adds postcss packages needed for Tailwind support if ng-packagr is already installed.",
      "factory": "./src/migrations/update-13-0-0/add-postcss-packages",
      "package": "@nrwl/angular",
      "name": "add-postcss-packages"
    },
    {
      "cli": "nx",
      "version": "13.2.0-beta.1",
      "description": "Remove deprecated options from webpack-server and webpack-browser.",
      "factory": "./src/migrations/update-13-2-0/update-angular-config",
      "package": "@nrwl/angular",
      "name": "update-angular-config"
    },
    {
      "cli": "nx",
      "version": "13.2.0-beta.1",
      "description": "Remove enableIvy and add compilationMode to library tsconfig and remove deprecated ng-packagr options.",
      "factory": "./src/migrations/update-13-2-0/update-libraries",
      "package": "@nrwl/angular",
      "name": "update-libraries"
    },
    {
      "cli": "nx",
      "version": "13.2.0-beta.1",
      "description": "Update jest config to support jest-preset-angular",
      "factory": "./src/migrations/update-13-2-0/update-angular-jest-config",
      "package": "@nrwl/angular",
      "name": "update-angular-jest-config"
    },
    {
      "cli": "nx",
      "version": "13.2.0-beta.1",
      "description": "Move some imports from @nrwl/angular/testing to jasmine-marbles",
      "factory": "./src/migrations/update-13-2-0/update-testing-imports",
      "package": "@nrwl/angular",
      "name": "update-testing-imports"
    },
    {
      "cli": "nx",
      "version": "13.2.0",
      "description": "In Angular version 13, the `teardown` flag in `TestBed` will be enabled by default. This migration automatically opts out existing apps from the new teardown behavior.",
      "factory": "./src/migrations/update-13-2-0/opt-out-testbed-teardown",
      "package": "@nrwl/angular",
      "name": "opt-out-testbed-teardown"
    },
    {
      "cli": "nx",
      "version": "13.3.0-beta.0",
      "description": "In Angular version 13, the ESM became a first class citizen. This means the webpack config generated must be modified to support modules.",
      "factory": "./src/migrations/update-13-3-0/update-mfe-webpack-config",
      "package": "@nrwl/angular",
      "name": "update-mfe-config-to-module-syntax"
    },
    {
      "cli": "nx",
      "version": "13.4.5-beta.7",
      "description": "Remove the default for the invalid 'style' option for the library generator if configured.",
      "factory": "./src/migrations/update-13-5-0/remove-library-generator-style-default",
      "package": "@nrwl/angular",
      "name": "remove-library-generator-style-default"
    },
    {
      "cli": "nx",
      "version": "13.5.0-beta.0",
      "description": "A lot of changes to how MFEs operate were discovered and merged without appropriate migrations. This should cover migrating existing MFEs to the latest, using ESM and optmized production bundles.",
      "factory": "./src/migrations/update-13-5-0/update-mfe-configs",
      "package": "@nrwl/angular",
      "name": "fix-incorrect-mfe-setups"
    },
    {
      "cli": "nx",
      "version": "13.8.1",
      "description": "Angular doesn't attach styles.js to index.html with type=module in dev mode, meaning an error is written to the console. Cypress falls over on this error. Add logic to Cypress e2e projects to ignore this error.",
      "factory": "./src/migrations/update-13-8-1/add-cypress-mfe-workaround",
      "package": "@nrwl/angular",
      "name": "add-cypress-mfe-workaround"
    },
    {
      "cli": "nx",
      "version": "13.8.4",
      "description": "Karma coverage is broken since Angular 13 upgarde and the karma config is severely out of date. Bring it up to date fixing the coverage issue.",
      "factory": "./src/migrations/update-13-8-4/migrate-karma-conf",
      "package": "@nrwl/angular",
      "name": "migrate-karma-config"
    },
    {
      "version": "13.0.0",
      "factory": "./update-13/schematic-options",
      "description": "Remove no longer valid Angular schematic options from `angular.json`.",
      "package": "@angular/cli",
      "name": "schematic-options-13"
    },
    {
      "version": "13.0.0",
      "factory": "./update-13/update-angular-config",
      "description": "Remove deprecated options from 'angular.json' that are no longer present in v13.",
      "package": "@angular/cli",
      "name": "update-angular-config-v13"
    },
    {
      "version": "13.0.0",
      "factory": "./update-13/update-libraries",
      "description": "Update library projects to be published in partial mode and removed deprecated options from ng-packagr configuration.",
      "package": "@angular/cli",
      "name": "update-libraries-v13"
    },
    {
      "version": "13.0.0",
      "factory": "./update-13/drop-ie-polyfills",
      "description": "Remove polyfills required only for Internet Explorer which is no longer supported.",
      "package": "@angular/cli",
      "name": "drop-ie-polyfills"
    },
    {
      "version": "13.0.0",
      "factory": "./update-13/update-gitignore",
      "description": "Updating '.gitignore' to include '.angular/cache'.",
      "package": "@angular/cli",
      "name": "update-gitignore"
    },
    {
      "version": "13.0.0-beta",
      "description": "Migrates `[routerLink]=\"\"` in templates to `[routerLink]=\"[]\"` because these links are likely intended to route to the current page with updated fragment/query params.",
      "factory": "./migrations/router-link-empty-expression/index",
      "package": "@angular/core",
      "name": "migration-v13-router-link-empty-expression"
    },
    {
      "version": "13.0.0-beta",
      "description": "In Angular version 13, the `teardown` flag in `TestBed` will be enabled by default. This migration automatically opts out existing apps from the new teardown behavior.",
      "factory": "./migrations/testbed-teardown/index",
      "package": "@angular/core",
      "name": "migration-v13-testbed-teardown"
    },
    {
      "version": "13.1.0-beta",
      "description": "As of Angular version 13, `entryComponents` are no longer necessary.",
      "factory": "./migrations/entry-components/index",
      "package": "@angular/core",
      "name": "migration-v13.1-entry-components"
    },
    {
      "version": "13.0.0-0",
      "description": "Updates Angular Material to v13",
      "factory": "./ng-update/index#updateToV13",
      "package": "@angular/material",
      "name": "migration-v13"
    },
    {
      "version": "13.0.0-0",
      "description": "Updates the Angular CDK to v13",
      "factory": "./ng-update/index#updateToV13",
      "package": "@angular/cdk",
      "name": "migration-v13"
    },
    {
      "version": "13.1.2-beta.0",
      "cli": "nx",
      "description": "Support .test. file names in tsconfigs",
      "factory": "./src/migrations/update-13-1-2/update-tsconfigs-for-tests",
      "package": "@nrwl/jest",
      "name": "update-ts-config-for-test-filenames"
    },
    {
      "version": "13.4.4-beta.0",
      "cli": "nx",
      "description": "Create a root babel config file if it doesn't exist and using babel-jest in jest.config.js and add @nrwl/web as needed",
      "factory": "./src/migrations/update-13-4-4/add-missing-root-babel-config",
      "package": "@nrwl/jest",
      "name": "add-missing-root-babel-config"
    },
    {
      "cli": "nx",
      "version": "13.3.0-beta.0",
      "description": "Update eslint-rules jest.config.js in order to support ESLint v8 exports mapping, remove category field",
      "factory": "./src/migrations/update-13-3-0/eslint-8-updates",
      "package": "@nrwl/linter",
      "name": "eslint-8-updates"
    }
  ]
}

nx report

Node : 16.13.1
   OS   : win32 x64
   yarn : 1.22.17
   nx : 12.9.0
   @nrwl/angular : 13.8.5
   @nrwl/cli : 12.9.0
   @nrwl/cypress : 13.8.5
   @nrwl/detox : undefined
   @nrwl/devkit : 13.8.5
   @nrwl/eslint-plugin-nx : 13.8.5
   @nrwl/express : undefined
   @nrwl/jest : 13.8.5
   @nrwl/js : undefined
   @nrwl/linter : 13.8.5
   @nrwl/nest : undefined
   @nrwl/next : undefined
   @nrwl/node : undefined
   @nrwl/nx-cloud : undefined
   @nrwl/react : undefined
   @nrwl/react-native : undefined
   @nrwl/schematics : undefined
   @nrwl/storybook : 13.8.5
   @nrwl/tao : 12.9.0
   @nrwl/web : undefined
   @nrwl/workspace : 13.8.5
   typescript : 4.5.5
   rxjs : 6.6.7
   ---------------------------------------
   Community plugins:
         @angular/animations: 13.2.7
         @angular/cdk: 13.2.6
         @angular/common: 13.2.7
         @angular/compiler: 13.2.7
         @angular/core: 13.2.7
         @angular/forms: 13.2.7
         @angular/material: 13.2.6
         @angular/platform-browser: 13.2.7
         @angular/platform-browser-dynamic: 13.2.7
         @angular/router: 13.2.7
         @ngneat/transloco: 2.23.3
         @angular-devkit/build-angular: 13.2.6
         @angular/cli: 13.2.6
         @angular/compiler-cli: 13.2.7
         @angular/language-service: 13.2.7

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:35 (6 by maintainers)

github_iconTop GitHub Comments

12reactions
dan-cookecommented, Jul 27, 2022

Literally just folowed the docs on creating a workspace and addding an application using @nrwl/nest and i encountered this error.

Don’t think this should be closed?

I’ve just started using nx 5 mintues ago and i’m blocked already lol

Edit

For anyone coming here from a search - turns out the nest package is missing a crucial line in the project.json

"sourceRoot": "apps/api/src",
  "projectType": "application",
  "root": "apps/api", // << add this
10reactions
CharlieGreenmancommented, Jun 11, 2022

When I came across this issue it had to do with projects being in my nx.json. Removing the entire projects object from the nx.json solved this issue. The migrate command should ideally remove it for the user depending on the version number.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NX Cannot read properties of undefined (reading 'endsWith')
NX Failed to run update-ngcc-postinstall from @nrwl/angular. This workspace is NOT up to date! NX rule is not a function. So I set...
Read more >
nx cannot read properties of undefined (reading 'endswith')
I have nx 14.4.3 version in my system. And when I run nx serve it gives me the error :- TypeError: Cannot read...
Read more >
Uncaught TypeError: Cannot read property 'endsWith ... - Drupal
Problem/Motivation This module gave following error: Uncaught TypeError: Cannot read property 'endsWith' of undefined Steps to reproduce I ...
Read more >
Error: Cannot read property "endsWith" of undefined
Hello, I have add a button to a page.... now I get error: Cannot read property "endsWith" of undefined Even if I delete...
Read more >
How to Avoid the Infamous "Cannot read properties of ... - Bitovi
As a JavaScript developer, I'm sure you've encountered the frustrating runtime TypeError Cannot read properties of undefined .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found