nx-labs: latest nx-ignore failing in vercel with latest nx release

Since nx 15.7.0 nx-ignore command is failing in vercel with the following error.

I tried degrading to nx 15.6.0 and this command works fine.

npm WARN exec The following package was not found and will be installed: nx-ignore@15.6.0
21:26:24.660 | ≫ Using Nx to determine if this project (app) is affected by the commit...
21:26:24.660 | ≫ Running from /vercel/.npm/_npx/cf7fc04e3df2a243/node_modules/nx-ignore/src
21:26:24.660 | ≫ Workspace root is /vercel/path0
21:26:24.665 | ≫ Creating temp folder to install Nx: /tmp/.nx-ignore
21:26:32.482 | npm WARN using --force Recommended protections disabled.
21:26:32.484 | ≫ Found Nx at version 15.7.0
21:26:32.485 |  
21:26:32.485 | ≫ Comparing HEAD^...HEAD
21:26:32.485 |  
21:26:42.141 | node:internal/errors:868
21:26:42.141 | const err = new Error(message);
21:26:42.141 | ^
21:26:42.141 |  
21:26:42.142 | Error: Command failed: npx nx print-affected --base=HEAD^ --head=HEAD
21:26:42.142 | at checkExecSyncError (node:child_process:885:11)
21:26:42.142 | at execSync (node:child_process:957:15)
21:26:42.142 | at /vercel/.npm/_npx/cf7fc04e3df2a243/node_modules/nx-ignore/src/index.js:67:24
21:26:42.142 | at Generator.next (<anonymous>)
21:26:42.143 | at asyncGeneratorStep (/vercel/.npm/_npx/cf7fc04e3df2a243/node_modules/@swc/helpers/lib/_async_to_generator.js:13:28)
21:26:42.143 | at _next (/vercel/.npm/_npx/cf7fc04e3df2a243/node_modules/@swc/helpers/lib/_async_to_generator.js:31:17)
21:26:42.143 | at /vercel/.npm/_npx/cf7fc04e3df2a243/node_modules/@swc/helpers/lib/_async_to_generator.js:36:13
21:26:42.143 | at new Promise (<anonymous>)
21:26:42.143 | at /vercel/.npm/_npx/cf7fc04e3df2a243/node_modules/@swc/helpers/lib/_async_to_generator.js:28:16 {
21:26:42.143 | status: 1,
21:26:42.144 | signal: null,
21:26:42.144 | output: [
21:26:42.144 | null,
21:26:42.144 | Buffer(89) [Uint8Array] [
21:26:42.144 | 10,  32,  62,  32,  32,  78,  88,  32,  32,  32,  67, 111,
21:26:42.144 | 117, 108, 100,  32, 110, 111, 116,  32, 102, 105, 110, 100,
21:26:42.144 | 32,  34,  46, 109, 111, 100, 117, 108, 101, 115,  46, 121,
21:26:42.144 | 97, 109, 108,  34,  32,  97, 116,  32,  34,  47, 118, 101,
21:26:42.144 | 114,  99, 101, 108,  47, 112,  97, 116, 104,  48,  47, 110,
21:26:42.145 | 46, 109, 111, 100, 117, 108, 101, 115,  46, 121,  97, 109,
21:26:42.145 | 108,  34,  10,  10,  10
21:26:42.145 | ],
21:26:42.145 | Buffer(0) [Uint8Array] []
21:26:42.145 | ],
21:26:42.145 | pid: 171,
21:26:42.145 | stdout: Buffer(89) [Uint8Array] [
21:26:42.145 | 10,  32,  62,  32,  32,  78,  88,  32,  32,  32,  67, 111,
21:26:42.146 | 117, 108, 100,  32, 110, 111, 116,  32, 102, 105, 110, 100,
21:26:42.146 | 32,  34,  46, 109, 111, 100, 117, 108, 101, 115,  46, 121,
21:26:42.146 | 97, 109, 108,  34,  32,  97, 116,  32,  34,  47, 118, 101,
21:26:42.146 | 114,  99, 101, 108,  47, 112,  97, 116, 104,  48,  47, 110,
21:26:42.146 | 111, 100, 101,  95, 109, 111, 100, 117, 108, 101, 115,  47,
21:26:42.146 | 46, 109, 111, 100, 117, 108, 101, 115,  46, 121,  97, 109,
21:26:42.146 | 108,  34,  10,  10,  10
21:26:42.146 | ],
21:26:42.146 | stderr: Buffer(0) [Uint8Array] []
21:26:42.147 | }
21:26:42.147

<br class="Apple-interchange-newline">

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 6
  • Comments: 16

Most upvoted comments

#329 fixes this issue for us. We can now do pnpm dlx nx-ignore project-name and everything works!

I was able to get @awilderink’s workaround working (with the help of @meshaabi 👏) by using corepack in the ignore step to ensure Vercel uses the correct version of pnpm. The ignore step was using pnpm v6 but we’re on v8.

corepack enable && corepack prepare pnpm@8.6.6 --activate && pnpm dlx nx show projects --affected --base=$VERCEL_GIT_PREVIOUS_SHA --head=$VERCEL_GIT_COMMIT_SHA | (! grep -q \"< your project >\")

Of course you’ll want to match your local pnpm version: I’d recommend placing this version in the packageManager package.json field and changing the prepare command to use this like so:

corepack enable && corepack prepare --activate && pnpm dlx nx show projects --affected --base=$VERCEL_GIT_PREVIOUS_SHA --head=$VERCEL_GIT_COMMIT_SHA | (! grep -q \"< your project >\")

Also, we found that there was no need to install the entire workspace dependencies in the build step. pnpm dlx nx worked fine for us but you may need to specify a version to match your version of nx.

Just wanted to check back in and say we removed this workaround and instead just not doing nx-ignore because the ignore step became so slow. Additionally, we had private dependencies and vercel doesn’t allow injecting any sort of npm token into the ignore step - so this is workaround no longer an option for us.

@mheob two weeks ago what was your nx version? It’s not shown in the screenshot probably you didn’t have verbose option back then. As I mentioned in the first comment I noticed the issue after upgrading NX to 15.7.0. But surprisingly, with latest NX and nx-ignore 15.5.0 worked together fine. npx nx-ignore@15.5.0 appName --verbose