nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.28k stars 2.32k forks source link

library build fails - "Cannot convert undefined or null to object" #8302

Closed nadavsinai closed 2 years ago

nadavsinai commented 2 years ago

Current Behavior

library build fails with this error trace

    at Function.keys (<anonymous>)
    at Object.updatePaths (F:\client-workspace-3\node_modules\@nrwl\workspace\src\utilities\buildable-libs-utils.js:147:30)
    at F:\client-workspace-3\node_modules\@nrwl\angular\src\executors\package\package.impl.js:48:36

the weird thing is that the build chain (6 dependencies) starts by running the target lib and finishes successfully

it then goes on to compile the dependencies and fails with the above error running build on any of the dependencies works fine I don't know what's different about this lib (from the 60~ projects this monorepo has)

Expected Behavior

lib builds fine, this is a regression as this used to work in NX11, this currently happens in a yet to be merged platform update to Angular 12 with NX 13.1.x

Steps to Reproduce

run build for this lib I can't provide the source publicly but as we are a NX cloud on-premise clients we can do an online support session

Environment

  Node : 16.13.1
  OS   : win32 x64
  yarn : 1.22.10

  nx : 13.1.4
  @nrwl/angular : 13.1.4
  @nrwl/cli : 13.1.4
  @nrwl/cypress : 13.1.4
  @nrwl/devkit : 13.1.4
  @nrwl/eslint-plugin-nx : 13.1.4
  @nrwl/express : Not Found
  @nrwl/jest : 13.1.4
  @nrwl/linter : 13.1.4
  @nrwl/nest : Not Found
  @nrwl/next : Not Found
  @nrwl/node : Not Found
  @nrwl/nx-cloud : 13.0.0
  @nrwl/react : Not Found
  @nrwl/schematics : Not Found
  @nrwl/tao : 13.1.4
  @nrwl/web : Not Found
  @nrwl/workspace : 13.1.4
  @nrwl/storybook : 13.1.4
  @nrwl/gatsby : Not Found
  typescript : 4.3.5

Further debugging info

this may relate to #https://github.com/nrwl/nx/issues/1044 and #https://github.com/nrwl/nx/issues/1455 but I've checked that my base tsconfig has paths property and that all projects have "architect" property in angular.json so the "solutions" there don't work for me

if I change the updatePaths function (workspaces/src/utilities/buildable-libs-utills.js:146) to have a default paths argument of {} I reach another error Error: ENOENT: no such file or directory, lstat 'F:/client-workspace-3/libs/report-browser/libs/wmdl-webkit/tsconfig.lib.json' this is intresting since the report-browser it the target lib to build and wmdl-webkit is one of the dependencies oviously not found in this path but as a sibling lib under libs

anyone has any idea?

nadavsinai commented 2 years ago

another weird issue, could be related. as I test the platform-update branch I found tests fail due to errors as such

Provided path to resolve: F:\client-workspace-3\libs\session-manager-client-ng\VEM\libs\archiveCommon
cwd: F:\client-workspace-3 

again session-manager-client-ng is a lib and archiveCommon (in VEM\libs) is another libs - those should be siblings but the error shows NX tried to find them with session-manage-client-ng being a PARENT for the archiveCommon dependency - just like the build error.

I managed to get rid of those error by commenting out the root jest.config.js (which exported a list of projects using the getJestProjects helper from @nrwl/jest

FrozenPandaz commented 2 years ago

Sorry, I can't get enough information here to help with the issue. Please provide a repo that exhibits the issue to help us debug the issue.

nadavsinai commented 2 years ago

I found the solution to this one. it was due to running nx build in project folder rather than in workspace root. I'm not speaking about the original build command invoked by the user but about a dependency build I triggered from code in webpack.config (if output does not exist build app X - thais is dynamically used within the target app and needs the compiled assets for copying into the target app assets) I made my own helper for that as previous versions NX lacked the ability to declare other builds being an implicit dependency, somehow my utility build runner used to run fine in the past (even though not invoked in root folder) and in NX 13 it failed. IMHO this should be possible too, and if not - a better error should be displayed so not closing the issue, but perhaps this should be tracked otherwise.

nadavsinai commented 2 years ago

BTW - the solution is not related to that error which I didn't get to research yet

another weird issue, could be related. as I test the platform-update branch I found tests fail due to errors as such

Provided path to resolve: F:\client-workspace-3\libs\session-manager-client-ng\VEM\libs\archiveCommon
cwd: F:\client-workspace-3 

again session-manager-client-ng is a lib and archiveCommon (in VEM\libs) is another libs - those should be siblings but the error shows NX tried to find them with session-manage-client-ng being a PARENT for the archiveCommon dependency - just like the build error.

I managed to get rid of those error by commenting out the root jest.config.js (which exported a list of projects using the getJestProjects helper from @nrwl/jest

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏

harjotsingh26 commented 2 years ago

(node:10772) UnhandledPromiseRejectionWarning: TypeError: Cannot convert undefined or null to object at Function.keys ()

harjotsingh26 commented 2 years ago

nx serve "backend-ms-apps"

(node:10772) UnhandledPromiseRejectionWarning: TypeError: Cannot convert undefined or null to object at Function.keys () at Object.assertWorkspaceValidity (E:\stackways-notification\Stackways-app\node_modules\@nrwl\workspace\src\core\assert-workspace-validity.js:8:35) at Object.createProjectGraph (E:\stackways-notification\Stackways-app\node_modules\@nrwl\workspace\src\core\project-graph\project-graph.js:14:33) at Object. (E:\stackways-notification\Stackways-app\node_modules\@nrwl\workspace\src\command-line\run-one.js:16:46) at Generator.next () at fulfilled (E:\stackways-notification\Stackways-app\node_modules\tslib\tslib.js:114:62)

github-actions[bot] commented 1 year ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.