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