knip icon indicating copy to clipboard operation
knip copied to clipboard

Cannot run `pnpm create @knip/config` in nx monorepo root

Open pavinduLakshan opened this issue 1 year ago • 1 comments

I was running pnpm create @knip/config in my nx monorepo root and the execution fails with the following error.

.../Library/pnpm/store/v3/tmp/dlx-15451  |   +1 +
.../Library/pnpm/store/v3/tmp/dlx-15451  | Progress: resolved 1, reused 1, downloaded 0, added 1, done
node:internal/errors:865
  const err = new Error(message);
              ^

Error: Command failed: pnpm add -D knip typescript @types/node
    at checkExecSyncError (node:child_process:885:11)
    at execSync (node:child_process:957:15)
    at main (file:///Users/pavindu/Library/pnpm/store/v3/tmp/dlx-15451/node_modules/.pnpm/@[email protected]/node_modules/@knip/create-config/index.js:26:3)
    at file:///Users/pavindu/Library/pnpm/store/v3/tmp/dlx-15451/node_modules/.pnpm/@[email protected]/node_modules/@knip/create-config/index.js:35:1
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25) {
  status: 1,
  signal: null,
  output: [
    null,
    Buffer(352) [Uint8Array] [
      226, 128, 137,  69,  82,  82,  95,  80,  78,  80,  77,  95,
       65,  68,  68,  73,  78,  71,  95,  84,  79,  95,  82,  79,
       79,  84, 226, 128, 137,  32,  82, 117, 110, 110, 105, 110,
      103,  32, 116, 104, 105, 115,  32,  99, 111, 109, 109,  97,
      110, 100,  32, 119, 105, 108, 108,  32,  97, 100, 100,  32,
      116, 104, 101,  32, 100, 101, 112, 101, 110, 100, 101, 110,
       99, 121,  32, 116, 111,  32, 116, 104, 101,  32, 119, 111,
      114, 107, 115, 112,  97,  99, 101,  32, 114, 111, 111, 116,
       44,  32, 119, 104,
      ... 252 more items
    ],
    Buffer(0) [Uint8Array] []
  ],
  pid: 15471,
  stdout: Buffer(352) [Uint8Array] [
    226, 128, 137,  69,  82,  82,  95,  80,  78,  80,  77,  95,
     65,  68,  68,  73,  78,  71,  95,  84,  79,  95,  82,  79,
     79,  84, 226, 128, 137,  32,  82, 117, 110, 110, 105, 110,
    103,  32, 116, 104, 105, 115,  32,  99, 111, 109, 109,  97,
    110, 100,  32, 119, 105, 108, 108,  32,  97, 100, 100,  32,
    116, 104, 101,  32, 100, 101, 112, 101, 110, 100, 101, 110,
     99, 121,  32, 116, 111,  32, 116, 104, 101,  32, 119, 111,
    114, 107, 115, 112,  97,  99, 101,  32, 114, 111, 111, 116,
     44,  32, 119, 104,
    ... 252 more items
  ],
  stderr: Buffer(0) [Uint8Array] []
}

Node.js v18.17.0

It seems like pnpm add doesn't work in nx/pnpm workspace root unless -w flag is provided. Is there a way to run pnpm create @knip/config in monorepo root without errors?

pavinduLakshan avatar Jul 11 '24 19:07 pavinduLakshan

Thanks for the report! I think we should add the -w for pnpm in monorepos. Would you like to submit a pull request?

webpro avatar Jul 11 '24 20:07 webpro

It's happening with yarn

node:internal/errors:983
  const err = new Error(message);
              ^

Error: Command failed: yarn add -W -D knip typescript @types/node
    at genericNodeError (node:internal/errors:983:15)
    at wrappedFn (node:internal/errors:537:14)
    at checkExecSyncError (node:child_process:888:11)
    at execSync (node:child_process:960:15)
    at main (file:///private/var/folders/7t/x_27lndd5lz_qt50v0jfdygc0000gn/T/xfs-107abe5b/dlx-5250/node_modules/@knip/create-config/index.js:44:3)
    at file:///private/var/folders/7t/x_27lndd5lz_qt50v0jfdygc0000gn/T/xfs-107abe5b/dlx-5250/node_modules/@knip/create-config/index.js:53:1
    at ModuleJob.run (node:internal/modules/esm/module_job:268:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:543:26)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5) {
  status: 1,
  signal: null,
  output: [
    null,
    Buffer(233) [Uint8Array] [
       27,  91,  51,  49, 109,  27,  91,  49, 109,  85, 110, 107,
      110, 111, 119, 110,  32,  83, 121, 110, 116,  97, 120,  32,
       69, 114, 114, 111, 114,  27,  91,  50,  50, 109,  27,  91,
       51,  57, 109,  58,  32,  85, 110, 115, 117, 112, 112, 111,
      114, 116, 101, 100,  32, 111, 112, 116, 105, 111, 110,  32,
      110,  97, 109, 101,  32,  40,  34,  45,  87,  34,  41,  46,
       10,  10,  36,  32, 121,  97, 114, 110,  32,  97, 100, 100,
       32,  91,  45,  45, 106, 115, 111, 110,  93,  32,  91,  45,
       69,  44,  45,  45,
      ... 133 more items
    ],
    Buffer(0) [Uint8Array] []
  ],
  pid: 5255,
  stdout: Buffer(233) [Uint8Array] [
     27,  91,  51,  49, 109,  27,  91,  49, 109,  85, 110, 107,
    110, 111, 119, 110,  32,  83, 121, 110, 116,  97, 120,  32,
     69, 114, 114, 111, 114,  27,  91,  50,  50, 109,  27,  91,
     51,  57, 109,  58,  32,  85, 110, 115, 117, 112, 112, 111,
    114, 116, 101, 100,  32, 111, 112, 116, 105, 111, 110,  32,
    110,  97, 109, 101,  32,  40,  34,  45,  87,  34,  41,  46,
     10,  10,  36,  32, 121,  97, 114, 110,  32,  97, 100, 100,
     32,  91,  45,  45, 106, 115, 111, 110,  93,  32,  91,  45,
     69,  44,  45,  45,
    ... 133 more items
  ],
  stderr: Buffer(0) [Uint8Array] []
}

Node.js v22.11.0

julianCast avatar Dec 26 '24 11:12 julianCast