sahilrajput03 / nvm-autoswitching

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

README

NVM: Docs

Inspiration: here

Set default version of nvm

nvm alias default 20.12.0
# Other versions 16.14.2, etc.
nvm use default

Creating a .nvmrc file

node -v > .nvmrc

FYI: You can simply write 12 or 14 for corresonding node versions as well as I have done in this current demo.

What to do to make autoswitching seamlessly?

In your .bashrc file you can have something like below and then autoswitching of node versions will happen quite amazingly!

nvmUse () {
	if [ -f ".nvmrc" ]; then
		nvm use
	fi
}

function cd {
    # actually change the directory with all args passed to the function
    builtin cd "$@"

	nvmUse
}

About