nrwl / nx

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

TypeError: Cannot read properties of undefined (reading 'split') #27736

Open ThePlenkov opened 1 week ago

ThePlenkov commented 1 week ago

Current Behavior

I try to build my package and get the error like this:

 npx nx build codegen
Convert compiler options from json failed, Cannot read file '/tsconfig.base.json'.

 NX   Cannot read properties of undefined (reading 'split')

Pass --verbose to see the stacktrace.

with verbose it looks like this:

 npx nx build codegen --verbose
Convert compiler options from json failed, Cannot read file '/tsconfig.base.json'.

 NX   Cannot read properties of undefined (reading 'split')

TypeError: Cannot read properties of undefined (reading 'split')
    at /workspace/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:256:58
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Promise.all (index 1)
    at async buildProjectGraphAndSourceMapsWithoutDaemon (/workspace/node_modules/nx/src/project-graph/project-graph.js:80:31)
    at async createProjectGraphAndSourceMapsAsync (/workspace/node_modules/nx/src/project-graph/project-graph.js:208:25)
    at async createProjectGraphAsync (/workspace/node_modules/nx/src/project-graph/project-graph.js:198:39)
    at async Object.runOne (/workspace/node_modules/nx/src/command-line/run/run-one.js:24:26)
    at async handleErrors (/workspace/node_modules/nx/src/utils/params.js:22:24)
    at async Object.handler (/workspace/node_modules/nx/src/command-line/run/command-object.js:32:26)

Expected Behavior

I expect to see the real reason why my script has failed, but currently it fails just handling another errors

GitHub Repo

No response

Steps to Reproduce

I do not know how to reproduce, but there can be a chance when we have not an error, but an empty object in the following code contruction:

image

The error later happens in this code: https://github.com/nrwl/nx/blob/3cbe2abc25c3b3763b4def6d9a84b299b571f7c5/packages/nx/src/project-graph/utils/project-configuration-utils.ts#L374

Nx Report

nx report
Convert compiler options from json failed, Cannot read file '/tsconfig.base.json'.

 NX   Report complete - copy this into the issue template

Node           : 20.16.0
OS             : linux-x64
Native Target  : x86_64-linux
npm            : 10.8.1

nx (global)        : 19.6.4
nx                 : 19.6.3
@nx/js             : 19.6.3
@nx/jest           : 19.6.3
@nx/linter         : 19.6.3
@nx/eslint         : 19.6.3
@nx/workspace      : 19.6.3
@nx/devkit         : 19.6.3
@nx/eslint-plugin  : 19.6.3
@nx/plugin         : 19.6.3
@nx/rollup         : 19.6.3
@nrwl/tao          : 19.6.3
@nx/vite           : 19.6.3
@nx/web            : 19.6.3
typescript         : 5.5.4
---------------------------------------
Registered Plugins:
@nx/eslint/plugin
@nx/jest/plugin
---------------------------------------
⚠️ Unable to construct project graph.
Cannot read properties of undefined (reading 'split')
TypeError: Cannot read properties of undefined (reading 'split')
    at /workspace/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:256:58
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Promise.all (index 1)
    at async buildProjectGraphAndSourceMapsWithoutDaemon (/workspace/node_modules/nx/src/project-graph/project-graph.js:80:31)
    at async createProjectGraphAndSourceMapsAsync (/workspace/node_modules/nx/src/project-graph/project-graph.js:208:25)
    at async createProjectGraphAsync (/workspace/node_modules/nx/src/project-graph/project-graph.js:198:39)
    at async tryGetProjectGraph (/workspace/node_modules/nx/src/command-line/report/report.js:138:25)
    at async getReportData (/workspace/node_modules/nx/src/command-line/report/report.js:106:49)
    at async Object.reportHandler (/workspace/node_modules/nx/src/command-line/report/report.js:46:167)
    at async Object.handler (/workspace/node_modules/nx/src/command-line/report/command-object.js:8:9)

Failure Logs

No response

Package Manager Version

No response

Operating System

Additional Information

No response

ThePlenkov commented 1 week ago

BTW I managed to find the reason - I have created a root level tsconfig.json with following content:

{
    "extends": "../tsconfig.base.json",
    "compilerOptions": {
        "experimentalDecorators": true
    }
}

So it was pointing to not existing config and one of plugins was generating the exception error TS5083: Cannot read file '/tsconfig.base.json'. which has no stack, just symbol: image

But it doesn't deny the fact that such errors must be properly handled by the framework