I couldn't find in the docs how .nvmrc should be formatted. Is there an example in this repository?
.nvmrc should take any <versionish> where "versionish" is defined by nvm --help output.
I'd love a PR to add more clarity to the README.
+1
If you're currently using the Node version you want for .nvmrc, you can run this command:
node -v > .nvmrc
to generate a .nvmrc file for you :)
Here's an actual example of the entire contents of a .nvmrc file:
v12.4.0
Could I also write v12 to stay on the most recent version of node12?
Yep. Any “versionish” will work, see nvm --help
I think the version without v also works.
12.4.0
I happened to know it because I got an pull request from renovate bot at https://github.com/Hongbo-Miao/hongbomiao.com/pull/141
And Netlify can still pick the right Node.js version based on the .nvmrc file.
@Hongbo-Miao yes, see the comment i made immediately prior to yours.
Can you add comments to .nvmrc?? I want to add documentation why a certain version was chosen.
@mctrafik no, currently nvm just reads the entire contents of the line. surely git log .nvmrc should tell you why a certain version was chosen?
It may be worth noting that the version should not be quoted.
@ethagnawl i … suppose we could, but shell arguments (with spaces or asterisks in them) are the only things that would be quoted, so i'm not sure why there'd be any expectation that .nvmrc should be quoted?
Sorry if my comment was unclear. I was attempting to say that people should be sure not to use quoted values in the .nvmrc (e.g. pulling a specific version from a package.json's engines entry.). I was not requesting that support for quotes be added.
Right - I guess I'm not convinced that's a common problem. What I'd rather do is make nvm able to provide a special error message if the value is wrapped in quotes but otherwise correct.
Most helpful comment
If you're currently using the Node version you want for .nvmrc, you can run this command:
node -v > .nvmrcto generate a .nvmrc file for you :)