Skip to content

support per-package node version specification in workspaces #6720

@mark-omarov

Description

@mark-omarov

Describe the user story

Reference to the original discussion - #6569.

Considering pnpm now has its own Node Version Manager - working in a multi-package workspace environment, I want the ability to specify individual Node.js versions for each package within the workspace. Currently, the use-node-version option in the .npmrc file is only recognized at the root level. This would enhance pnpm by allowing seamless, per-project version switching, eliminating the need for other tools.

Describe the solution you'd like

I gave a couple of potential solutions in the discussions, with the one enabling pnpm to read .npmrc files from individual packages being the favorite. This is likely the solution I'm looking to implement.

Describe the drawbacks of your solution

  • It may introduce compatibility issues for existing workflows that rely on current behavior
    It's probably minor, I don't think many would have multi-package.npmrc and use-node-version defined for other than the root.
  • Performance would suffer a little as we will load configurations for all selected packages
  • It may have unexpected implications for other commands besides run, but I'll see during the implementation

Perhaps to mitigate drawbacks, we could feature-flag it?

Describe alternatives you've considered

We could modify @pnpm/npm-conf to resolve the version from the individual package in a workspace instead of the workspace's root. But after some digging, I figured it was probably not worth it. We would need to modify the @pnpm/npm-conf and change in what order configurations and projects graphs are loaded, which is trickier to implement. Also, that library should probably stay unconcerned about workspace support specifics.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Priority

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions