nx icon indicating copy to clipboard operation
nx copied to clipboard

@nx/next doesn't respect nested package versions in pnpm workspace

Open tom-sherman opened this issue 1 year ago • 0 comments

Current Behavior

When using pnpm workspaces, versions are not resolved using the project's node_modules when the same package is installed in the workspace root.

Expected Behavior

If a package is installed in a workspace project, the version of local package should be used.

GitHub Repo

https://github.com/tom-sherman/nx-next-workspace-resolution-bug/tree/main

Steps to Reproduce

  1. pnpm i
  2. nx serve foo-app

Nx Report

Node   : 20.9.0
   OS     : darwin-arm64
   pnpm   : 8.14.0
   
   nx (global)        : 17.0.3
   nx                 : 17.2.8
   @nx/js             : 17.2.8
   @nx/jest           : 17.2.8
   @nx/eslint         : 17.2.8
   @nx/workspace      : 17.2.8
   @nx/eslint-plugin  : 17.2.8
   @nx/next           : 17.2.8
   @nx/react          : 17.2.8
   @nrwl/tao          : 17.0.3
   typescript         : 5.2.2
   ---------------------------------------
   The following packages should match the installed version of nx
     - @nrwl/[email protected]
   
   To fix this, run `nx migrate [email protected]`

Failure Logs

No response

Package Manager Version

No response

Operating System

  • [X] macOS
  • [ ] Linux
  • [ ] Windows
  • [ ] Other (Please specify)

Additional Information

I've tested this with a Next.js project inside of a pnpm workspace without NX and it works correctly. There seems to be something about how nx is executing next.js from a different location that causes the issue (as in a a pnpm workspace you would executute next dev from within the project itself, not the root)

tom-sherman avatar Jan 28 '24 23:01 tom-sherman