setup-node icon indicating copy to clipboard operation
setup-node copied to clipboard

Support `use-node-version` value in `.npmrc`

Open dr3 opened this issue 1 year ago • 4 comments

Description: Allow node-version-file value of .npmrc and read use-node-version key

Justification: This method of defining is quite popular, and is documented for use by pnpm https://pnpm.io/npmrc#use-node-version

Are you willing to submit a PR? Yep if desired

dr3 avatar Sep 11 '24 17:09 dr3

Hello @dr3, Thank you for creating this feature request and we will get back to you once we have some feedback on this :)

aparnajyothi-y avatar Sep 12 '24 14:09 aparnajyothi-y

Hello @dr3, Thank you for your suggestion and for referencing PNPM’s support for the use-node-version field in .npmrc. We appreciate the thought you’ve put into how this feature could streamline version management and enhance compatibility for PNPM users. After internal review, we’ve decided not to move forward with this enhancement at this time. While we recognize the potential value it could bring to specific workflows, we haven’t seen enough broader demand or adoption to justify the added complexity and maintenance this feature would introduce.

We’ll continue to monitor interest in this area and are open to revisiting the idea in the future as the ecosystem evolves. We appreciate your contribution and encourage you to share any additional feedback to help guide future improvements.

aparnajyothi-y avatar May 15 '25 09:05 aparnajyothi-y

Hello everyone, We’ve noticed some concerns reflected by the reactions to the previous message. We truly appreciate the community’s honest feedback and want to assure you that every suggestion is carefully considered.

Our decision to pause on this enhancement is based on weighing the broader impact and maintenance overhead alongside current demand. We remain open to revisiting this in the future as more users express interest or as the ecosystem evolves.

Thank you for your continued engagement and for helping us prioritize improvements that benefit the wider community.

aparnajyothi-y avatar May 30 '25 08:05 aparnajyothi-y

While I would prefer it being built in, I was able to implement this functionality myself via the following composite action that we use in-place of calling setup-node directly (though we use NVM it should work for .npmrc with minimal changes):

name: Node Setup
description: Utility to setup node with version from .nvmrc
outputs:
  node_version:
    description: 'The version of node installed'
    value: ${{ steps.get-node-version.outputs.node_version }}

runs:
  using: 'composite'
  steps:
    - name: Get Node Version
      id: get-node-version
      shell: bash
      # Get the version from the .nvmrc file. (Note: cut -c2- removes the starting 'v' from the version number)
      run: echo "node_version=$(cat .nvmrc | cut -c2-)" >> "$GITHUB_OUTPUT"

    - name: Setup Node
      uses: actions/[email protected]
      with:
        node-version: ${{ steps.get-node-version.outputs.node_version }}

Furthermore this step also exposes the version on it's outputs so you can use it elsewhere in your workflow (we use it to base our Docker image on the same node version)

Ionshard avatar Oct 08 '25 14:10 Ionshard