question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

It would be nice if setup-node understood an .nvmrc file (even if it does not use nvm under the hood, the idea is the node-version is just the contents of the file).

If GitHub Actions as a whole could read the contents of a file as part of an expression, I could do something like

uses: setup-node@v1
with:
  node-version: {{ contents(.nvmrc) }}

But I don’t know where to log that type of feature request!

Perhaps ‘.nvmrc’ could be used as a special placeholder, so that:

uses: setup-node@v1
with:
  node-version: '.nvmrc'

Instructs this action to read the contents and treat the contents as the desired version?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:162
  • Comments:34 (7 by maintainers)

github_iconTop GitHub Comments

94reactions
mauriciabadcommented, Nov 16, 2022

If you got here from googling, let me tell you, that the newest and simplest way of reading the .nvmrc file and using it in actions/setup-node is with the node-version-file option:

  - name: Setup node
    uses: actions/setup-node@v3
    with:
      node-version-file: '.nvmrc'
52reactions
damccormcommented, Aug 28, 2019

Sorry, had a lapse when I wrote this. Try changing your workflow to:

- name: Read .nvmrc
  run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)"
  id: nvm

- name: Use Node.js (.nvmrc)
  uses: actions/setup-node@v1
  with:
    node-version: "${{ steps.nvm.outputs.NVMRC }}"

Env variables are scoped to a given step so they don’t automatically carry over, but we can use outputs instead.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to write a .nvmrc file which automatically change node ...
This makes it having a builtin support to switch node version automatically. Auto version switch in nodenv doesn't have to be hooked on ......
Read more >
Node version doesn't loaded via .nvmrc : WEB-45434
I've installed multiple Node.js versions. In the project is specified via .nvmrc file v14.1.0 (default Node version is 11.15.0) If try commit changes, ......
Read more >
Guarantee a Single Version of Node.js In All Environments
nvmrc file, and all GitHub Actions used LTS (long-term support, which at the time was v14). Since the new major version of this...
Read more >
Specify Node Versions with .nvmrc
nvmrc is specifying that Node.js v16 should be used. Any developer could then run nvm use to download, install, and switch to that...
Read more >
Automated Dependency Updates for nvm - Renovate Docs
Renovate supports updating nvm dependencies. File Matching¶. By default, Renovate will check any files matching the following regular expression: (^|/)\.nvmrc$ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Hashnode Post

No results found