-
Notifications
You must be signed in to change notification settings - Fork 54
Read node version from package.json #10
Comments
That field is a) information-only, and b) identifies what something is supported with. That field can't be easily used to test a new version. |
I'm open to the idea of using another field in Here are some use cases that come to mind:
Another argument against this would be keeping things similar to the ruby tools, but there's not really a strongly compelling reason to do that. At this point, I think it makes sense to stick with the |
@ljharb, with regard to (a), isn't the Wouldn't the As for (b), could you explain the deficiencies in the |
If #17 is completed, this may be less likely to change. It would complicate the code base to support |
This would be handy. It's a little annoying having to keep the node version for our project up to date in 2 places. One simple pass would be to ignore it if an exact version is not specified. |
@mockdeep the only concern now is that Also, we would need to handle the file differently when it's read. I'm open to these changes, and would want to decide if |
I just wanted to chime in on this; We already use |
Other than that - love this - great work! :) |
@eiriklv |
@ljharb isn't that a good thing? :-) |
My point is - when this works really well on Heroku - why shouldn't it work great anywhere else..? |
Is the issue here shortcomings of the tool (that it only supports a specific version)? |
@eiriklv no shortcomings with So if you specify I don't consider this a problem — that's just how it works at the moment. Currently I don't see the problem with a semver range in |
My main point here is - why add another (duplicate) reference to the node version when you already specify it in |
The optimal solution would be that avn would tell n or nvm to install/use the latest available version in the specified semver range Edit: And thus behaving the same way on your local machine as on Heroku (as an example) |
@eiriklv that's more or less the intention, but without support from It selects the lasted available version that's installed locally, not that's available out on the internet. It could fetch a list of known node versions, but it would then require a network connection which has two issues:
|
Note that |
I'd be okay with choosing the most recent matching version that is installed. If people put a range, then they are responsible for dealing with the inconsistencies across versions themselves. Instead of installing it can just say "no compatible version of node installed" or the like.
|
What is the status of this? I was going to open an issue related with setup a default version if |
@Kikobeats this is still in the discussion phase — implementing this will require a decent number of changes. It also requires that we make decisions that are logical and appropriate for the community. Feel free to weigh in on the points discussed so far and continue the discussion. |
I think that is the right way. Now node devs need to handle with different node versions and is horrible the current workflow. Could be implemented with backward compatibility: if less is more! |
So what is the status of this issue now? It's been a year since it was opened. |
@sodatea still discussing, but I'm leaning toward it being a good idea. I'm happy to accept a PR, but we still do need to figure out what key it should look for in |
I'm using nodengine for this purpose, more simple 😄 |
Is
@wbyoung, what would be wrong with |
That’s a range, not a single version. |
@ljharb doesn't |
I believe that’s typically a single version. nvmrc is a “version-ish” which can be a range, but is expected to resolve to a single version. |
I don't get it. What do you mean by "typically a single version"? To me it has exactly the same meaning as "engines" fields in packages.json — it specifies node versions that are compatible with my project. |
The engines field is a semver range; it can describe nvmrc is a specifier that points to a single version implicitly. When you type it, you’re referring to a range of possible versions, but your intention is that it resolves to a single one. Conceptually, these are for two very different purposes, and the engines field isn’t a concept that directly maps to “a single node version to install”. |
Maybe the problem is that we are talking about different stuff? I am not really familiar with
Sorry, I still don't get it. Wherever you use it, you'll end up with one resolved version of node, no?
So I use it to specify version of node that my stuff works on. Then, for example, when my CI tries to build my stuff, it can look into this field and check wether version of node is ok and if not. Now, I need to do the same thing, but for all developers who works on my stuff. I use What am I missing? |
(nvmrc and node-version are the same, conceptually) |
Yes, you certainly can take a range and end up with one resolved version - this isn’t a technical barrier, it’s a conceptual one. The mental model of “engines” is simply not appropriate to apply to “which node version should i be using with the project by default” because they are distinct concepts. It’s certainly valid for you to chose to make them have identical texts (not that node-version of nvmrc should be semver; they’re a subset) - but that doesn’t mean that choice should be foisted on everyone else (iow, the things i put in the engines field for my packages should never be used to select which version to use, so this tool shouldn’t do that) |
How are you using it? You are using narrower range or specific version in
I don't see what causes this conclusion. In official docs I see nothing about mental model of this field. It only says:
To me, it means: |
I mean, if I am specifying versions of Node which my app supports, it would be strange that I am prohibiting some of them from using in development. No? |
@Bessonov that’s both full of a bunch of false claims and also off topic for the thread; let’s not get into that. |
@rusty-key nope. Babel 7 requires node 6+, for example, but i have packages using it that support back to node 0.10. I also have a repo where we have binary deps that require node 8 for dev, but the package works fine in production from 0.10 - 11. |
Works fine and guaranteed to work fine are not the same. If I specify "engine", I give you some kind of guarantee that my package works with these node versions. It still can work with other versions, but I cannot be sure for some reasons. Anyway, even if we decide that version file and engines field have different mental models (which I am still not convinced in 😄), I don't see how it prevents |
I don’t think that would be correct, no - i think the engines field is to declare compatibility, and can’t ever be correctly used to determine version switching absent an additional signal. |
Hey guys, are there any udpates on this? |
@DmitriyAA I'm still at a point of not feeling convinced either way as to whether it's a good idea or a bad one. |
Perhaps I'm missing something, but why not use the package.json? why are we creating another meta file that duplicates a piece of information about node that can already be stored in the package.json?
The text was updated successfully, but these errors were encountered: