{"id":184,"date":"2021-03-02T20:10:05","date_gmt":"2021-03-02T20:10:05","guid":{"rendered":"https:\/\/andrejacobs.org\/?p=184"},"modified":"2022-04-11T20:24:24","modified_gmt":"2022-04-11T20:24:24","slug":"installing-node-js-on-macos-big-sur-using-nvm","status":"publish","type":"post","link":"https:\/\/andrejacobs.org\/macos\/installing-node-js-on-macos-big-sur-using-nvm\/","title":{"rendered":"Installing Node.js on macOS Big Sur using nvm"},"content":{"rendered":"\n
Photo by Lukas Hellebrand<\/a> on Unsplash<\/a><\/p>\n\n\n\n I recently clean installed macOS Big Sur and is in the process of setting up all my software. As part of the spring cleaning process I wanted to clear out all of the GitHub forks that I accumulated like a snowball.<\/p>\n\n\n\n To help in this process I found delete-github-forks<\/a> that can bulk delete GitHub forks and this tool is written using Node.js<\/p>\n\n\n\n So I thought it would be a good idea to document how I install node on macOS Big Sur.<\/p>\n\n\n\n Get the latest command line script to be run from https:\/\/github.com\/nvm-sh\/nvm<\/a> and then run the command in the terminal. It is always a good idea to first read the script before just blindly running it.<\/p>\n\n\n\n The script will make changes to Note:<\/strong> If you don’t have a Then I verify the changes made to Relaunch the terminal and verify To install the latest version of node.<\/p>\n\n\n\n Verify the version of node being used.<\/p>\n\n\n\n To install a different version of node.<\/p>\n\n\n\n List the installed versions.<\/p>\n\n\n\nInstalling nvm<\/h2>\n\n\n\n
nvm<\/code> (node version manager)<\/a> allows you to have multiple versions of node installed and thus help avoid compatibility issues when projects use different versions of node.<\/p>\n\n\n\n
.zshrc<\/code> so I backup mine first and then install
nvm<\/code>.<\/p>\n\n\n\n
.zshrc<\/code> file yet then you need to create it first (
touch ~\/.zshrc<\/code>)<\/p>\n\n\n\n
$ cp .zshrc .zshrc.bak\n$ curl -o- https:\/\/raw.githubusercontent.com\/nvm-sh\/nvm\/v0.37.2\/install.sh | bash<\/code><\/pre>\n\n\n\n
.zshrc<\/code><\/p>\n\n\n\n
$ diff .zshrc .zshrc.bak\n40,43d39\n<\n< export NVM_DIR=\"$HOME\/.nvm\"\n< [ -s \"$NVM_DIR\/nvm.sh\" ] && \\. \"$NVM_DIR\/nvm.sh\" # This loads nvm\n< [ -s \"$NVM_DIR\/bash_completion\" ] && \\. \"$NVM_DIR\/bash_completion\" # This loads nvm bash_completion<\/code><\/pre>\n\n\n\n
nvm<\/code><\/p>\n\n\n\n
$ nvm -v\n0.37.2<\/code><\/pre>\n\n\n\n
Installing node<\/h2>\n\n\n\n
$ nvm install node<\/code><\/pre>\n\n\n\n
<\/figure><\/div>\n\n\n\n
$ nvm run node --version\nRunning node v15.10.0 (npm v7.5.3)\nv15.10.0\n\nYou can also now just use node directly\n$ node --version\nv15.10.0<\/code><\/pre>\n\n\n\n
$ nvm install 14.16.0\n$ nvm use 14.16.0<\/code><\/pre>\n\n\n\n
$ nvm ls<\/code><\/pre>\n\n\n\n