-
Notifications
You must be signed in to change notification settings - Fork 154
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
Use package.json engines version? #60
Comments
If we have both But what to do if
Also, take into an account that the version inside the Would you rather install the version from |
Replying to @MrQubo's questions with an opinion.
In a subdirectory, any legacy file, or For a range of versions, the latest version allowable, and installed, should be used, if available. The last question seems to point to automatic installation, which I do not believe is reasonable. If a specified version is not available, that would be an error. |
After looking at this a bit more, I don't think we should add support for this. Adding support for this would require a lot of code. Here is the PR for nvm (which isn't going to be merged) - nvm-sh/nvm#1535. It is over 1200 lines of code. I think my biggest objection to this is that it doesn't make sense semantically.
package.json specifies a version or range of versions that the package is compatible with, whereas |
Here is a PR that attempts to add support for package.json - #120. The problem with this PR is that the engine value isn't a plain version that can be used by asdf-nodejs. We would have to address all the issues nvm would have to address on their PR. |
Closing since I don't think this makes sense as a feature. Please comment if you think I should re-open this ticket. |
@Stratus3D I would really like to see support for What if we compromised and asdf supported strings that have a specific version without semver syntax? So if it had Thoughts? |
@augustobmoura what do you think about that? I suppose it wouldn't really break asdf-nodejs semantics, but would it be worth the hassle to implement? |
+1 I would love to see this feature in asdf. There are already so many files that need to be in the root of a project and package.json already officially has a field that designates what version should be used. Following DRY, we should use package.json. Fringe Use Benefit: I imagine this feature would also be useful in some cases where the latest version of Node causes a break -- with the ">=14.0.0" specified in package.json, this would force developers to have their code tested with the latest version before sending it off to a public registry. In regard to @Stratus3D 's comment about nvm's implementation being over 1200 lines -- most of the code is test code/mock data for the tests. The actual bash script logic is about 300 lines in the If we brought this feature to asdf, we could probably recycle the code from the nvm commit. I don't have the bandwidth to pick this up currently plus I'm not in active communication with the maintainer but I'd be willing to fund the PR by giving an NFT of a girl's fart in a jar to see this get done (Source: https://news.bitcoin.com/wind-breaking-nfts-reality-star-who-made-200k-selling-farts-in-mason-jars-launches-nft-collection/) |
I just came here to suggest this feature to be implemented, but before opening a new issue, I've searched and found this issue already opened. I think this feature would be very welcome. Should be disabled by default and explicitly enabled through configuration Is there a way to print an alert message in terminal when the directory is navigated to ? Another observation is that the implementation of this feature should be simpler as possible, nothing more than check if exists a package.json file, parse it as JSON, check the presence of the "engines.node" field filled, validate it with a regular expression, and resolve the version, keeping the behavior aligned as if the version was read from .toolversion. My suggestion to solve the question raised about the engines.node field allowing the semver format which in some cases may not be compatible with asdf, the field must be validated using the regular expression found on the official website https://semver.org, and in case of failure, ignore and use the default strategy. It should also be clear in the documentation that in order to use package.json as a source of information for the node.js version, the engines.node field must be in a format compatible with the format expected by asdf. Otherwise, it makes no sense to use package.json as a replacement for .toolversions. |
Thoughts on reading the engines object from package.json to select the correct nodejs version?
nvm-sh/nvm#651
The text was updated successfully, but these errors were encountered: