Automatically switch node versions based on package.json recommended engine.
Automatically switch node versions through nvm based on package.json recommended engine version.
NVM
installed:
git clone https://github.com/Nick-Gabe/nvm-switcher.git
.zshrc
, .bashrc
, $profile
...nvm use $(node <directory>/nvm-switcher)
<directory>
by the directory the repository is in.After all those steps, once you open a shell, it will automatically execute the nvm-switcher
command and find the optimal version for you.
git clone https://github.com/<user>/nvm-switcher.git
# replace <user> with your username
Since we're talking about node versions, you should already have node in your system,
therefore using javascript
provides a more understandable code and easier API than
bash
for example.
But this might change at some point, due to javascript
not being the most optimal
language in terms of speed for this kind of operation which requires running terminal commands.