-
-
Notifications
You must be signed in to change notification settings - Fork 8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Honor .node-version file #794
Comments
When did Which would win if you had both files present? What about the different version formats that |
Ah sorry, my mistake, it wasn't
I think I'd expect
That's a good question - I'll have to research this a bit. |
I'd never heard of |
+1 Rapid, per-project .ruby-version switching with rvm is too useful not to have this for Node.js! |
👍 |
I think the idea here is that even though As @ljharb pointed out though, interoperability here would require more than just a common filename. |
If all of |
Just for .nvmrc files - https://github.com/lalitkapoor/nvm-auto-switch - I appreciate any feedback. Thanks! |
Please use github reactions on the original post rather than posting "+1". Fair warning, I'll clean up existing and future comments that simply say that. |
That's not a problem, at all...
Project owners could decide to use a wider syntax on I don't even think |
I'm not sure if I even like this idea, but a generic approach to "supporting" node-version directly might be to support a syntax in nvmrc that allows people to read the version string from any other file.
This approach does have some pleasant side effects:
|
That's not a half-bad idea. However, I'll think about that one more. |
.node-version is a much more sane name than .nvmrc furthermore, I don't see why it shouldn't support both |
@TylerBre please don't use ableist terms like "sane".
|
Even though nvm support io.js, |
io.js is node, versions 1-3, after the fact. You're also missing the most important part, which is "aliases". |
The purpose of |
I agree - which would mean that What do |
nodenv differentiates between node and iojs with definitions like |
Does |
My assumption was it wouldn't work with the
rvm I don't know, but rbenv does, as is about the same as nodenv (nodenv is a port of rbenv) |
That's encouraging - it means we could support Either way I've filed nodejs/version-management#13, and I think this issue should be blocked on that. |
I just swung by to leave an issue and see if there was any interest in this, but looks like there is! RVM and rbenv both have their own files and formats but both agree on Here's how RVM load the file:
So, we could very easily add another function to check for |
Here you go! #1625 |
Nope, I don't typically commit to timelines on releases, let alone on making decisions :-) The best way to help is to help take things off my plate - for nvm, the main blocker right now is converting travis tests to use Github Actions. |
What else? Add '.nvmrc' also since nvm doesn't respect '.node-version' yet. Ref: nvm-sh/nvm#794
This comment was marked as abuse.
This comment was marked as abuse.
This comment was marked as resolved.
This comment was marked as resolved.
Snark or no it's a fair point. It seems pretty clear All this has already been said before though; there's little point in repeating it ad infinitum. Upvote and move on. |
Summary: IMO, there's no value in having `.node-version` files either in the repository or the template. I don't believe it's standard practice, the support from tooling is patchy (at least `nvm` [ignores it](nvm-sh/nvm#794), and Node is often used without a version manager), and it's unnecessarily restrictive when it is actually enforced. In every other case, it's potentially misleading noise. Libraries should use `package.json#engines` to specify their Node JS compatibility ranges, as indeed `react-native` [already does](https://github.com/facebook/react-native/blob/1629b9f0a11f42ff12c6dd06a20afb80067e4958/package.json#L10). React Native users may wish to add one to their own projects according to their own setup or team, but we shouldn't confuse the issue by including an arbitrary one in the template. Changelog: [General][Removed] Remove `.node_version` from app template. Differential Revision: D43421085 fbshipit-source-id: 37558ef3aee6479b40746cccf83beb1577473786
Summary: Pull Request resolved: #36208 IMO, there's no value in having `.node-version` files either in the repository or the template. I don't believe it's standard practice, the support from tooling is patchy (at least `nvm` [ignores it](nvm-sh/nvm#794), and Node is often used without a version manager), and it's unnecessarily restrictive when it is actually enforced. In every other case, it's potentially misleading noise. Libraries should use `package.json#engines` to specify their Node JS compatibility ranges, as indeed `react-native` [already does](https://github.com/facebook/react-native/blob/1629b9f0a11f42ff12c6dd06a20afb80067e4958/package.json#L10). React Native users may wish to add one to their own projects according to their own setup or team, but we shouldn't confuse the issue by including an arbitrary one in the template. Changelog: [General][Removed] Remove `.node_version` from app template. Reviewed By: jacdebug, blakef Differential Revision: D43421085 fbshipit-source-id: 37a9b0fb7701f06fffb867dbc7ecac479b4d9c95
Can anyone write a shell script to automatically load a.node-version file like a.nvmrc file in nvm readme? |
Summary: Pull Request resolved: facebook#36208 IMO, there's no value in having `.node-version` files either in the repository or the template. I don't believe it's standard practice, the support from tooling is patchy (at least `nvm` [ignores it](nvm-sh/nvm#794), and Node is often used without a version manager), and it's unnecessarily restrictive when it is actually enforced. In every other case, it's potentially misleading noise. Libraries should use `package.json#engines` to specify their Node JS compatibility ranges, as indeed `react-native` [already does](https://github.com/facebook/react-native/blob/1629b9f0a11f42ff12c6dd06a20afb80067e4958/package.json#L10). React Native users may wish to add one to their own projects according to their own setup or team, but we shouldn't confuse the issue by including an arbitrary one in the template. Changelog: [General][Removed] Remove `.node_version` from app template. Reviewed By: jacdebug, blakef Differential Revision: D43421085 fbshipit-source-id: 37a9b0fb7701f06fffb867dbc7ecac479b4d9c95
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Somehow both n and fnm are able to support both .nvmrc and .node-version files. I would love to not need to create both files, when using any of the many other tools that recognize .node-version. This seems like such an inconsequential thing, and absolutely improves the nvm user's experience, that it's pretty surprising to me that this discussion has been ongoing for almost 9 years. Whether there are ongoing discussions around what standards .node-version should take or not, it's already become a defacto standard for many libraries. |
Add this to your nvm-use() {
# Print usage on -h or --help
if [[ "$#" -eq 1 && ("$1" == "-h" || "$1" == "--help") ]]; then
echo "Usage: nvm-use [nvm use options]"
echo ""
echo "- This function will look for a .node-version file in the current directory,"
echo " and run 'nvm use' with the version specified in that file."
echo "- If no .node-version file is found, it will run 'nvm use' with"
echo " the arguments passed to this function."
echo "- Note: This function might no longer be needed when this issue is solved:"
echo " https://github.com/nvm-sh/nvm/issues/794"
echo ""
echo "Options:"
echo " -h, --help Show this help message and exit."
return 0
fi
# Check for .node-version file and use its version if available
if [[ $# -eq 0 && -f .node-version ]]; then
local node_version
node_version=$(<.node-version)
node_version="${node_version//v/}" # Optionally remove 'v' prefix
nvm use "$node_version"
else
echo "No .node-version file found. Falling back to 'nvm use' with default arguments."
nvm use "$@"
fi
} |
Looks like every other tool supports |
Forgive me if this has been discussed before, but I didn't find anything beyond #110 (comment).
It would be really nice to see the various Node version managing tools coalesce around a common "version config file", analogous to Ruby's
.ruby-version
for RVM and rbenv -.node-version
. This would basically just be an alias for.nvmrc
, since that functionality's already been added. Sincen
already supports.node-version
, this would make it so that regardless of the Node version manager used, there could be some degree of guarantee that the correct version will be used.The text was updated successfully, but these errors were encountered: