If you already have ndenv
on your computer you need to remove it (it's not supported anymore).
Remove commands related to ndenv
from ~/.bash_profile
file:
# remove those lines
export PATH="$HOME/.ndenv/bin:$PATH"
eval "$(ndenv init -)"
Remove ndenv
:
$ rm -rf ~/.ndenv
Install nodenv and add initializer in .bash_profile
:
brew install nodenv
eval "$(nodenv init -)" # add it to .bash_profile
By default nodenv
uses node-build
package to get information about available nodejs
versions. This package can have outdated information. To get latest available node version you need to install node-build-update-defs plugin and run update-version-defs
command:
git clone https://github.com/nodenv/node-build-update-defs.git "$(nodenv root)"/plugins/node-build-update-defs
nodenv update-version-defs
nodenv
uses .node-version
file to understand which version of nodejs
should be used. By default you need to specify full version number here (e.g. 10.13.0). It's not very convenient (e.g if you decide to update dependency to next minor version (e.g. 10.13.1) you will need to update this version in .node-version
file and your teammate will have to do the same thing). To prevent such problem you can use nodenv-aliases
plugin. With this plugin you can specify major version in .node-version
file and this symlink will point to different minor versions for different teammates. Clone this plugin:
git clone https://github.com/nodenv/nodenv-aliases.git $(nodenv root)/plugins/nodenv-aliases
Install latest node.js
version (e.g. 20.5.1) and create alias for it:
nodenv install 20.5.1
nodenv global 20.5.1
nodenv alias 20 --auto