Skip to content

Feature request: Support .node-version to specify the version #206

Closed

Description

@karszawa

I'm using nodenv to handle a lot of versions of node binaries on my computer. It provides a .node-version file to change node version based on the current directory. So, I specify the local node version by .node-version as well as setup-node input in GitHub Actions.

In this case, I want to make a .node-version file the only place where the node version is notated. To achieve this, I sometimes read .node-version and provide the result to setup-node like this:

	steps:
	  - uses: actions/checkout@v1

      - name: Read .node-version
        run: echo ::set-output name=NODE_VERSION::$(cat .node-version | cut -c 2-)
        id: nvm

      - name: Setup Node.js
        uses: actions/setup-node@v2
        with:
          node-version: ${{ steps.nvm.outputs.NODE_VERSION }}

This is acceptable, but I think it is a better option for setup-node to have node-version-file as another way to specify the node version like this:

	steps:
	  - uses: actions/checkout@v1

      - name: Setup Node.js
        uses: actions/setup-node@v2-beta
        with:
          node-version-path: '.node-version' # it should be configurable for something like monorepo project which does not have .node-version on the root

I'm willing to implement this feature if the team accepts the idea. Thanks for reading my proposal 😄

Activity

  1. jasonkarns commented on Feb 6, 2021

    @jasonkarns

    FWIW, nodenv has an action that will read the .node-version file for you specifically to enable passing that version to setup-node: https://github.com/nodenv/actions-node-version

  2. ruscon commented on Mar 13, 2021

    @ruscon

    this solution is better
    #239

  3. jasonkarns commented on Mar 15, 2021

    @jasonkarns

    @ruscon what, in your opinion, makes it "better"? I personally think a version-manager agnostic implementation (using a file that isn't version-manager specific) should be preferred.

  4. ruscon commented on Mar 15, 2021

    @ruscon

    @jasonkarns "better" => "generic"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions