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
NVM (node module) not honoring default node version #1956
Comments
So find that the module is calling Is there is any reason behind this behaviour? or was an intended change? |
I think the goal was to make nvm loading lazy - it's pretty slow to start up without |
Bump - this is still an issue for me. |
This bit me on a new install and took awhile to figure out where the issue was. I think it's worth exploring how to make nvm/node load faster but I'd revert the |
Orthogonally, I would suggest using fnm as it lightyears ahead of nvm in loading times and is API compatible |
I put this at the end of autoload -U add-zsh-hook
load-nvmrc() {
local node_version="$(nvm version)"
local nvmrc_path="$(nvm_find_nvmrc)"
if [ -n "$nvmrc_path" ]; then
local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
if [ "$nvmrc_node_version" = "N/A" ]; then
nvm install
elif [ "$nvmrc_node_version" != "$node_version" ]; then
nvm use
fi
elif [ "$node_version" != "$(nvm version default)" ]; then
echo "Reverting to nvm default version"
nvm use default
fi
}
add-zsh-hook chpwd load-nvmrc
load-nvmrc Update: Please see #1956 (comment) below - @indrajitr |
This pretty much sums up the reason behind the change. This was part of a series of changes back then to optimize startup time as much as possible. While I don't have the benchmark data available at this moment, for this specific change in isolation the overall reduction in startup time was significant. I agree the change is an irritant and did consider adding an inline warning to alert users. But I couldn't figure out a way to do it in a way without nagging users every time a new shell is opened. Suggestions, or even better, a PR is very welcome. |
See docs for more and please exercise caution before throwing this into |
Description
Since af46875,
node
module no longer honornvm
default NodeJS version.Expected behavior
node
module should honornvm
default version when opening a new terminal / session.Actual behavior
NodeJS version in new opened terminal sessions is always
system
.Steps to Reproduce
nvm
(curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
).nvm install 12
,nvm install 14
)apt install nodejs
)node
zprezto module in.zpreztorc
nvm
NodeJS versions as defaultnvm alias default 12
nvm ls
, it will besystem
instead of the previously setup default version.Already tested
nvm
in isolation outside ofzprezto
and works as expected.Versions
The text was updated successfully, but these errors were encountered: