nx: I'm trying to run nx serve and get: NX Cannot read properties of undefined

Current Behavior

Migration to v13. After that, when running “nx serve <project>” I got: NX Cannot read properties of undefined ('reading endsWith')

Also: NX As of Nx 13, project configuration should be moved from nx.json to workspace.json/project.json. Please run "nx format" to fix this.

Running “nx format”:

      NX   Affected criteria defaulted to --base=main --head=HEAD
      NX   Nx Daemon was not able to compute the project graph.
         Log file with the error: /Users/Arturo/aclprojects/acl-customers/node_modules/.cache/nx/d/daemon-error.log
         Please file an issue at https://github.com/nrwl/nx
         Nx Daemon is going to be disabled until you run "nx reset".
      
      NX As of Nx 13, project configuration should be moved from nx.json to workspace.json/project.json. Please run "nx format" to fix this.
      NX   Cannot read properties of undefined (reading 'endsWith')`

Expected Behavior

My service running

Steps to Reproduce

nx serve <project> after migration to v13. nx format

Failure Logs

daemon-error.log daemon.log

Environment

      NX   Report complete - copy this into the issue template
  
      Node : 16.13.1
      OS   : darwin x64
      yarn : 1.22.15
     
      nx : 13.8.1
     @nrwl/angular : 13.8.1
     @nrwl/cli : 13.8.1
     @nrwl/cypress : 13.8.1
     @nrwl/detox : undefined
     @nrwl/devkit : 13.8.1
     @nrwl/eslint-plugin-nx : 13.8.1
     @nrwl/express : undefined
     @nrwl/jest : 13.8.1
     @nrwl/js : undefined
     @nrwl/linter : 13.8.1
     @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.1
     @nrwl/tao : 13.8.1
     @nrwl/web : undefined
     @nrwl/workspace : 13.8.1
     typescript : 4.5.5
     rxjs : 7.5.4
     ---------------------------------------
     Community plugins:
 @angular/animations: 13.2.2
 @angular/cdk: 13.2.2
 @angular/common: 13.2.2
 @angular/compiler: 13.2.2
 @angular/core: 13.2.2
 @angular/forms: 13.2.2
 @angular/material: 13.2.2
 @angular/platform-browser: 13.2.2
 @angular/platform-browser-dynamic: 13.2.2
 @angular/router: 13.2.2
 angular-datatables: 13.0.1
 ngx-spinner: 13.1.1
 @angular-devkit/build-angular: 13.2.3
 @angular/cli: 13.2.3
 @angular/compiler-cli: 13.2.2
 @angular/language-service: 13.2.2

      (node:18220) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module resolution of the package at /Users/Arturo/aclprojects/acl-customers/node_modules/tslib/package.json.
      Update this package.json to use a subpath pattern like "./*".
      (Use `node --trace-deprecation ...` to show where the warning was created)`

About this issue

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

Commits related to this issue

Most upvoted comments

Hi @alo,

I hit the same issue migrating from angular & @nrwl v12 to v13. I debugged a little bit and found out that in nx.json, the ‘root’ property for each projects object should be present /as @leosvelperez suggested/

nx.json:

...
"projects": {
        "your-lib-name-1": {
            "tags": [],
            "root": "<the root of the lib>" <<<--- same root listed for the lib in angular.json
        },
        ...
}
...

after this, you may need to run the nx format command I hope this helps. At least it solved my issue.

Thanks for reporting this!

I had a look at the stack traces shared by @amakhrov here and the one in the daemon.log file shared by @aclarturocastro. Checking the source code, it looks like you might have a project in your configuration with no value specified for the root property. That property is required and therefore, it would cause issues when it’s not present.

Please make sure that all projects always have a root property set in the configuration.

I’ll close this issue since it seems to be caused by an invalid configuration and in some cases seem to be because the migrations were not run. Please feel free to reopen this if the above doesn’t fix the issue.

I just deleted all the libs in projects key on nx.json file and ran nx-format. It worked for me

Saw this nx.json example

Hope it works for you!

Same here. Migrating to v13, running nx format, getting the error

TypeError: Cannot read property 'endsWith' of undefined\n" +
    '    at createProjectRootMappings (<root>/node_modules/@nrwl/workspace/src/core/file-map-utils.js:12:38)\n' +
    '    at createProjectFileMap (<root>/node_modules/@nrwl/workspace/src/core/file-map-utils.js:27:33)\n' +
    '    at <root>/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 (<root>/node_modules/@nrwl/workspace/node_modules/tslib/tslib.js:114:62)\n' +
    '    at processTicksAndRejections (internal/process/task_queues.js:95:5)',
  message: "Cannot read property 'endsWith' of undefined\n" 

hope this answer help someone

@aclarturocastro did you find a way to fix this? I have run into the exact same issue after doing the v13 migration and then running `nx format’

Ok, I got it.

I tried to commit after each step of nx migrate. We also have a pre-commit hook, that runs nx format:write. This hook fails if I try to commit changes after installing new packages but before running --run-migrations

Hey Jason

I provided a couple of weeks ago a private repo… were you able to review it? Arturo Castro

El lun, 14 feb 2022 a la(s) 17:13, Jason Jean @.***) escribió:

Sorry, could you please provide a repo that the team can use to reproduce the issue.

— Reply to this email directly, view it on GitHub https://github.com/nrwl/nx/issues/8968#issuecomment-1039668262, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFMFEKKEXDA7LMMILVCSHDDU3GEB3ANCNFSM5OMLRPTQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>