npm run format:write should complete without errors
npm run format:write fails with error "Command line too long"
We have several long library + path + file names, that result in a command line for prettier that is too long.
NX already uses chunks (see: packages/schematics/src/command-line/format.ts), but the chuck size of 70 is too large for us.
When we decrease the chunk size to 50, all is well, and format:write runs happily.
Please provide detailed steps for reproducing the issue.
I'm using NX 8.0, but verified that the latest code still uses a chunk side of 70.
Full log available on request, but basically:
The command line is too long.
C:\Data\shared-workspace\node_modules\@nrwl\workspace\node_modules\yargs\yargs.js:1109
else throw err
^
Error: Command failed: node "C:\Data\shared-workspace\node_modules\@nrwl\workspace\node_modules\prettier\bin-prettier.js" --write <lots and lots of files here>
at checkExecSyncError (child_process.js:610:11)
at Object.execSync (child_process.js:646:15)
at write (C:\Data\shared-workspace\node_modules\@nrwl\workspace\src\command-line\format.js:84:25)
at C:\Data\shared-workspace\node_modules\@nrwl\workspace\src\command-line\format.js:42:40
at Array.forEach (<anonymous>)
at Object.format (C:\Data\shared-workspace\node_modules\@nrwl\workspace\src\command-line\format.js:42:23)
at Object.handler (C:\Data\shared-workspace\node_modules\@nrwl\workspace\src\command-line\nx-commands.js:72:98)
at Object.runCommand (C:\Data\shared-workspace\node_modules\@nrwl\workspace\node_modules\yargs\lib\command.js:235:44)
at Object.parseArgs [as _parseArgs] (C:\Data\shared-workspace\node_modules\@nrwl\workspace\node_modules\yargs\yargs.js:1022:30)
at Object.get [as argv] (C:\Data\shared-workspace\node_modules\@nrwl\workspace\node_modules\yargs\yargs.js:965:21) {
status: 1,
signal: null,
output: [ null, null, null ],
pid: 8968,
stdout: null,
stderr: null
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] format:write: `nx format:write`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] format:write script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\****\AppData\Roaming\npm-cache\_logs\2020-01-22T09_18_07_616Z-debug.log
Process finished with exit code 1
This is a relatively easy fix. Would someone from the community like to contribute a fix?
@FrozenPandaz Thanks for the fix.
I was wondering though, wouldn't it be possible to do this a bit more intelligently, by calculating what the length would be, adding additional chucks as space permits?
@FrozenPandaz I am getting this issue in 8.4.8, do I need to move to 9.3 version ?
Most helpful comment
This is a relatively easy fix. Would someone from the community like to contribute a fix?