When switching directories, first compare current and target Node version before proceeding, and abort AVN activation if they are the same
See original GitHub issueThanks for the great free software.
My project uses multiple different repositories, and each has their own individual directory locally. When I change to one directory, avn sets up the version of node per the .node-version file in the target directory. This is desirable.
However, when I change to another directory which contains another .node-version file having exactly the same contents, avn once again goes through the setup process.
I suggest that when changing directories and switching node versions, avn should, before proceeding with anything else, compare the current and target versions of Node, and if they are the same, then abort the setup process rather than forcing the user to wait a few seconds.
Here is some sample output:
hyperion:project chad$ cd api
avn activated 8.6.0 (avn-nvm v8.6.0)
hyperion:api chad$ cd ../app
avn activated 8.6.0 (avn-nvm v8.6.0)
hyperion:app chad$ cd ../admin
avn activated 8.6.0 (avn-nvm v8.6.0)
hyperion:admin chad$
As you can see, Node 8.6.0 was unnecessarily activated multiple times.
Details
- avn
0.2.3 - node
8.6.0 - nvm
0.33.8 - zsh
zsh 5.3 (x86_64-apple-darwin17.0) - bash
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin17)
The output of __avn_debug in the directory with a .node-version file is:
avn activated 8.6.0 (avn-nvm v8.6.0)
nvm use v8.6.0 > /dev/null;
avn is loaded in my ~/.{bash|zsh}{_profile|rc} file with:
[[ -s "$HOME/.avn/bin/avn.sh" ]] && source "$HOME/.avn/bin/avn.sh" # load avn
nvm specific
- As an
nvmuser I am confirming that I did not install with Homebrew
Issue Analytics
- State:
- Created 5 years ago
- Reactions:10
- Comments:6 (2 by maintainers)

Top Related StackOverflow Question
Came here to support this issue because I just noticed this happening on my machine. It’s a bit pointless to try to activate a version that it’s currently in use. In my particular machine takes a few seconds to switch, which is cumbersome when the versions are the same and there’s not need for switching.
Uhm…I didn’t think about such a situation of using both
nandnvm. Thanks for explaining.