nx
nx copied to clipboard
ERROR: nx migrate 17 to 18 - Unable to merge project information for project.json using plugin nx/core/project-json.
Current Behavior
I have this custom target in my project.json file
"my-custom-target": {
"executor": "nx:run-commands",
"configurations": {
"local": {
"commands": [
"my-local-command"
]
},
"cicd": {
"commands": [
"my-cicd-command"
]
}
},
"options": {
"cwd": "my/project/path"
}
}
When I try to migrate from nx 17 to 18 I get an error:
Unable to merge project information for "my-project/path" from my-project/path/project.json using plugin nx/core/project-json.
Inner Error: TypeError: Cannot read properties of undefined (reading 'join')
at isCompatibleTarget (C:\Source\my-project\node_modules\nx\src\project-graph\utils\project-configuration-utils.js:351:67)
at mergeTargetConfigurations (C:\Source\my-project\node_modules\nx\src\project-graph\utils\project-configuration-utils.js:290:26)
figuration-utils.js:111:34)
at C:\Source\my-project\node_modules\nx\src\project-graph\utils\project-configuration-utils.js:200:21
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async createProjectConfigurations (C:\Source\my-project\\node_modules\nx\src\project-graph\utils\retrieve-workspace-files.js:89:62)
at async processFilesAndCreateAndSerializeProjectGraph (C:\Source\my-project\node_modules\nx\src\daemon\server\project-graph-incremental-recomputation.js:140:28)
at async getCachedSerializedProjectGraphPromise (C:\Source\my-project\node_modules\nx\src\daemon\server\project-graph-incremental-recomputation.js:43:16)
at async handleRequestProjectGraph (C:\Source\my-project\node_modules\nx\src\daemon\server\handle-request-project-graph.js:12:24)
at async handleResult (C:\Source\my-project\node_modules\nx\src\daemon\server\server.js:110:16)
Because of the error the Nx daemon process has exited. The next Nx command is going to restart the daemon process.
If the error persists, please run "nx reset".
I believe this is due to https://github.com/nrwl/nx/blob/5971ae17f619acfa5d6801cd7fd991877b8d4cd1/packages/nx/src/project-graph/utils/project-configuration-utils.ts#L453 which could be updated so if both command / commands is undefined then it doesn't do the join?
Something like:
` if (isRunCommands) { const aCommands = a.options?.commands; const bCommands = b.options?.commands;
const aCommand = a.options?.command ?? (aCommands ? aCommands.join(' && ') : undefined);
const bCommand = b.options?.command ?? (bCommands ? bCommands.join(' && ') : undefined);
const oneHasNoCommand = !aCommand || !bCommand;
const hasSameCommand = aCommand === bCommand;
return oneHasNoCommand || hasSameCommand;
}
`
Expected Behavior
I believe my project.json file is OK so I expect the migration to work?
GitHub Repo
No response
Steps to Reproduce
- As above
Nx Report
Nx report results in the same error as above
Failure Logs
No response
Package Manager Version
npm 9.9.2
Operating System
- [ ] macOS
- [ ] Linux
- [X] Windows
- [ ] Other (Please specify)
Additional Information
No response
We are facing the same issue since version 18.0.0, now on 18.0.7 and still an issue. The use of Nx is completely broken, since the repo cannot be resolved at all. Even simple tasks such as running nx report don't work.
It seems that most if not all our apps cause an issue with an error like
NX Unable to merge project information for "apps/api-alerts-scheduler" from apps/api-alerts-scheduler/project.json using plugin nx/core/project-json.
Inner Error: TypeError: Cannot read properties of undefined (reading 'join')
at isCompatibleTarget (/Users/alexistrepanier/dev/assek/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:355:67)
at mergeTargetConfigurations (/Users/alexistrepanier/dev/assek/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:294:26)
at mergeProjectConfigurationIntoRootMap (/Users/alexistrepanier/dev/assek/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:111:34)
at /Users/alexistrepanier/dev/assek/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:204:21
at async createProjectConfigurations (/Users/alexistrepanier/dev/assek/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]/node_modules/nx/src/project-graph/utils/retrieve-workspace-files.js:89:62)
at async buildProjectGraphAndSourceMapsWithoutDaemon (/Users/alexistrepanier/dev/assek/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]/node_modules/nx/src/project-graph/project-graph.js:71:69)
at async createProjectGraphAndSourceMapsAsync (/Users/alexistrepanier/dev/assek/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]/node_modules/nx/src/project-graph/project-graph.js:136:25)
at async createProjectGraphAsync (/Users/alexistrepanier/dev/assek/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]/node_modules/nx/src/project-graph/project-graph.js:125:39)
at async Object.affected (/Users/alexistrepanier/dev/assek/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]/node_modules/nx/src/command-line/affected/affected.js:33:26)
Here is the project configuration for the project referenced in the error:
{
"name": "api-alerts-scheduler",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/api-alerts-scheduler/src",
"projectType": "application",
"targets": {
"build": {
"executor": "@nx/webpack:webpack",
"outputs": ["{options.outputPath}"],
"defaultConfiguration": "production",
"options": {
"outputPath": "dist/apps/api-alerts-scheduler",
"main": "apps/api-alerts-scheduler/src/main.ts",
"tsConfig": "apps/api-alerts-scheduler/tsconfig.app.json",
"assets": ["apps/api-alerts-scheduler/src/assets"],
"generatePackageJson": true,
"target": "node",
"compiler": "tsc",
"webpackConfig": "apps/api-alerts-scheduler/webpack.config.js"
},
"configurations": {
"production": {
"optimization": true,
"extractLicenses": true,
"inspect": false
},
"development": {
"optimization": true,
"extractLicenses": true,
"inspect": false
}
}
},
"serve": {
"executor": "@nx/js:node",
"defaultConfiguration": "development",
"options": {
"buildTarget": "api-alerts-scheduler:build"
},
"configurations": {
"production": {
"buildTarget": "api-alerts-scheduler:build:production"
},
"development": {
"buildTarget": "api-alerts-scheduler:build:development"
}
}
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"]
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/apps/api-alerts-scheduler"],
"options": {
"jestConfig": "apps/api-alerts-scheduler/jest.config.ts"
}
},
"deploy": {
"executor": "nx:run-commands",
"options": {},
"configurations": {
"production": {
"command": "bash ./infra/terraform/web-api/deploy-web-api.sh prod alerts-scheduler"
},
"development": {
"command": "bash ./infra/terraform/web-api/deploy-web-api.sh dev alerts-scheduler"
}
},
"inputs": [
"deploy-default",
"^production",
"{workspaceRoot}/infra/terraform/web-api/**/*",
"{workspaceRoot}/infra/terraform/common/**/*"
],
"defaultConfiguration": "development"
}
},
"tags": []
}
It does look like the issue is coming from the nx:run-commands executor. If I remove our custom target, the error seems to go away, but then the next app with the nx:run-commands fails.
@alextrep96 - try remove the empty options object in your deploy task.
@alextrep96 - try remove the empty options object in your deploy task.
That did the trick thanks!
@alextrep96 - try remove the empty options object in your deploy task.
Unfortunately that's not an option for my use case as the options object contains the required "cwd": "my/project/path" unless there's somewhere else it could be?
@alextrep96 - try remove the empty options object in your deploy task.
Unfortunately that's not an option for my use case as the options object contains the required
"cwd": "my/project/path"unless there's somewhere else it could be?
@craigbroadman - you didn't post your full project.json file, but I'd guess that a task in your file has an empty options object.
Hello ๐ - this should be fixed in latest, can you try updating your repository?
Hello ๐ - this should be fixed in latest, can you try updating your repository?
Thanks @AgentEnder, I should be able to take a look at this next week and will get back to you
This issue has been automatically marked as stale because no results of retrying on the latest version of Nx was provided within 7 days. It will be closed in 21 days if no results are provided. If the issue is still present, please reply to keep it active. If the issue was not present, please close this issue. Thanks for being a part of the Nx community! ๐
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.