-
-
Notifications
You must be signed in to change notification settings - Fork 738
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
Allow version matching against local downloaded versions, instead of always matching remote versions #727
Comments
Short version: working as intended Long version The current behaviour of version lookups is to consult the available downloads, rather than the local cached versions. By default There isn't currently an option to use the latest matching cached version. Another scenario that was raised in an earlier issue is no internet access: #404. You can check what versions are available locally with |
When there is version 14 on the user's computer, even if it is not the latest version, the local version should be used first when executing local version 14.19.1 n exec 14 npm -v expect behaviour 6.14.12 actual behaviour Error: '14' (14.19.3) not in downloads cache Both |
I don't think it likely I will change the default behaviour. There could be a new option to change the matching from "latest version according to Node.js" to "latest version already downloaded", as suggested in original post:
Would it affect all the version matching? e.g. |
Switch would be ok, but if possible make the switch available in a config file as well, so existing code will not break. |
The target_version=$(n ls | grep 'node/14.' | tail -n 1)
n exec "${target_version}" node --version |
The current behaviour is that unless the target version for a command is a fully qualified version number, then it will be resolved against the remote downloadable versions of Node.js. This works the same way for Historical note: I did consider using local matches when adding the partial match support for In v6.0.0 There could perhaps be a I'll leave this open for longer to see if there is more interest. |
This issue has not had any further activity in six months. Feel free to open a new issue if it comes up again, with new information and renewed interest. Thank you for your contributions. |
Added --offline option in n v9.2.0 |
Bug Report
Edit: original issue title was "n should use latest available version of node if installation is impossible".
Summary
When a new version of node gets released then n will start throwing errors instead of using latest available version
Steps to Reproduce
Expected Behaviour
Application should run showing
v14.19.2
, since that is the latest installed version of nodeand you don't have permissions to install a newer one (not root).
Actual Behaviour
Other Information
I am not sure if choosing between downloading and using preinstalled node should be done automatically.
Possibly
n exec
should never download node since in most cases it will not be possible either way(
n exec <app>
should never be run as root and only root can install new node version)Maybe having a switch to
download/use local
would be an option here as well.Configuration Details
$ n --version 8.2.0 $ command -v node /usr/local/bin/node $ node -p process.platform linux
The text was updated successfully, but these errors were encountered: