You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
If GitHub Actions as a whole could read the contents of a file as part of an expression
I think its probably unlikely we're going to expand our expression parsing to that degree - in general computation isn't supposed to happen there and we want to discourage moving in that direction, and keep that more towards just reading existing variables. Note that you could do something like the following here:
Perhaps '.nvmrc' could be used as a special placeholder
I'm interested in this option. We're looking at doing something similar in setup-dotnet: actions/setup-dotnet#15. I see a couple options here:
If there's a .nvmrc at the root of the repo (or the current working directory) and no node-version specified, automatically use the version in the .nvmrc file. Maybe have a variable that allows you to turn this on or off.
Allow node-version to be a path to a .nvmrc file.
Don't allow this option.
@chrispat, any thoughts on this one? I think maybe we should establish a pattern here and with setup-dotnet for similar requests (I'm sure node and dotnet aren't the only tools with config files that can specify versions).
Reacted by Doug Moscrop, Shota FUJI, Scott O'Hara, Matt Travi, Richard Simpson, Jackson Miller, Richard Clayton, Mitch Ryan, Abdel, Oliver Micke and 24 more
I think its probably unlikely we're going to expand our expression parsing to that degree - in general computation isn't supposed to happen there and we want to discourage moving in that direction, and keep that more towards just reading existing variables. Note that you could do something like the following here:
If there's a .nvmrc at the root of the repo (or the current working directory) and no node-version specified, automatically use the version in the .nvmrc file. Maybe have a variable that allows you to turn this on or off.
Allow node-version to be a path to a .nvmrc file.
Don't allow this option.
if it's helpful in making the decision, travis-ci has the behavior of 1. and is very often sufficient for my projects. it also has the benefit of removing the need to keep the versions in sync for what is intended for use with local development and the version intended for CI since there is a single source of truth rather than distributing across multiple files.
I think the action could be updated to support .nvmrc as the default if no version is specified in the node-version parameter. At the moment we do not have anyone we an assign to do that work in the action but it does feel like something we could code review as a community contribution.
I chatted with @bryanmacfarlane about this. I think for now we're going to close this issue, and instead move forward with the recommendation to just add nvm to the image as is requested in the virtual environments repo. actions/runner-images#4
Yeah, pretty straight forward and we haven't closed so we'll get to it at some point. Note that in your example above you should add shell: bash to your first run step if you want to ensure it works on windows as well
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:
Reacted by Mathias Bynens, Hugo Alliaume, Jason Suttles, Kabir Sarin, Patrick Connolly, Mathijs Kadijk, Peter Mescalchin, Juha Komulainen, Miroslav Hettes, Joshua May and 151 more
Reacted by Aaron Toomey, sainu, Valerio Riva, zrisher, Shubham N Khanna, Leunel, Daniel Seripap, Enrique Benitez, Rani, azpnellius and 20 more
Reacted by Apotheosis, Vasyl Zuziak, Yvonne Ng, Kav Singh, Pedro Mendes, Sergey Svekolnikov, Chachi Riccardi, Luis Lobo Borobia, Tom Gallacher, Emre Demir and 70 more
Reacted by Elias Martinez, Tomas Franco, dvolper, Lívia and Dan Wilt
I recently added this to my action and publishing started failing. I'm still trying to understand if this is the root cause, but I believe that setting node-version-file causes registry-url to be empty, which I'm not sure is the expected behavior.
Let me know if there's a need to open a different issue about it.
Activity
damccorm commentedon Aug 16, 2019
I think its probably unlikely we're going to expand our expression parsing to that degree - in general computation isn't supposed to happen there and we want to discourage moving in that direction, and keep that more towards just reading existing variables. Note that you could do something like the following here:
I'm interested in this option. We're looking at doing something similar in setup-dotnet: actions/setup-dotnet#15. I see a couple options here:
.nvmrcat the root of the repo (or the current working directory) and nonode-versionspecified, automatically use the version in the.nvmrcfile. Maybe have a variable that allows you to turn this on or off.node-versionto be a path to a.nvmrcfile.@chrispat, any thoughts on this one? I think maybe we should establish a pattern here and with setup-dotnet for similar requests (I'm sure node and dotnet aren't the only tools with config files that can specify versions).
dougmoscrop commentedon Aug 16, 2019
Thanks for the tip* about just using an output, that makes sense and is good enough for me, though the simpler developer experience would be nice.
chingc commentedon Aug 28, 2019
I tried to do this and it seems to be treating the environment variable as a literal instead of getting its value.
Here's the error and my config:
##[error]Unable to find Node version '${NVMRC}' for platform linux and architecture x64.damccorm commentedon Aug 28, 2019
Sorry, had a lapse when I wrote this. Try changing your workflow to:
Env variables are scoped to a given step so they don't automatically carry over, but we can use outputs instead.
chingc commentedon Aug 28, 2019
@damccorm That worked thank you!
travi commentedon Sep 28, 2019
if it's helpful in making the decision, travis-ci has the behavior of 1. and is very often sufficient for my projects. it also has the benefit of removing the need to keep the versions in sync for what is intended for use with local development and the version intended for CI since there is a single source of truth rather than distributing across multiple files.
peaceiris commentedon Oct 9, 2019
The following also works well.
chingc commentedon Mar 3, 2020
Has there been any progress towards natively supporting .nvmrc instead of having to use
set-output?thejoebourneidentity commentedon Mar 4, 2020
We got the following issue in the virtual environments repo: actions/runner-images#4
What's the latest on the plans to support .nvmrc? Is it on the roadmap?
chrispat commentedon Mar 4, 2020
I think the action could be updated to support .nvmrc as the default if no version is specified in the
node-versionparameter. At the moment we do not have anyone we an assign to do that work in the action but it does feel like something we could code review as a community contribution.thejoebourneidentity commentedon Mar 10, 2020
I chatted with @bryanmacfarlane about this. I think for now we're going to close this issue, and instead move forward with the recommendation to just add nvm to the image as is requested in the virtual environments repo. actions/runner-images#4
sarink commentedon Apr 2, 2020
cating an nvmrc file and using that version should be pretty simple, right?If you're not already using nvm under the hood to install node versions... Why add another dependency to the mix?
In any case
works, it's just really wordy to have to put it everywhere
bryanmacfarlane commentedon Apr 2, 2020
Yeah, pretty straight forward and we haven't closed so we'll get to it at some point. Note that in your example above you should add
shell: bashto your first run step if you want to ensure it works on windows as well21 remaining items
privatenumber commentedon Jun 1, 2021
Noticed errors weren't being caught when using
shell: bash -l {0}To make sure the GitHub Action fails correctly, make sure to use the
-eflag so that bash exists if a command exits with a non-zero status:For those looking to copy-paste, my workflow looks like this:
skjnldsv commentedon Jun 17, 2021
What I recently develpped to use the package.json engines
gordey4doronin commentedon Jul 1, 2021
Yet another variation. 👇 I guess no real advantages or disadvantages though.
Refactor the use of actions/setup-node
Refactor the use of actions/setup-node (#545)
jameswald commentedon Nov 30, 2021
Is this fixed with #338?
dougmoscrop commentedon Nov 30, 2021
I declare it fixed! I didn't say it, I declared it
mauriciabad commentedon Jan 3, 2022
If you got here from googling, let me tell you, that the newest and simplest way of reading the
.nvmrcfile and using it inactions/setup-nodeis with the node-version-file option:Simplify GitHub Action workflows
get rid of `browniebroke/read-nvmrc-action`, since `actions/setup-nod…
ci: update github actions (#587)
Github actions: use node version from nvmrc
Merge pull request actions#32 from akamai/feature/DEVPOPS-813
HarelM commentedon Nov 10, 2023
I recently added this to my action and publishing started failing. I'm still trying to understand if this is the root cause, but I believe that setting
node-version-filecausesregistry-urlto be empty, which I'm not sure is the expected behavior.Let me know if there's a need to open a different issue about it.