webpro-nl / knip

✂️ Find unused files, dependencies and exports in your JavaScript and TypeScript projects. Knip it before you ship it!
https://knip.dev
ISC License
7.06k stars 177 forks source link

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

Closed pavinduLakshan closed 4 months ago

pavinduLakshan commented 4 months ago

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/@knip+create-config@1.0.1/node_modules/@knip/create-config/index.js:26:3)
    at file:///Users/pavindu/Library/pnpm/store/v3/tmp/dlx-15451/node_modules/.pnpm/@knip+create-config@1.0.1/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?

webpro commented 4 months ago

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