From f4da02f3dee4ab75712937733305c01f3bd783a3 Mon Sep 17 00:00:00 2001 From: James Li Date: Sat, 21 May 2022 18:37:48 -0700 Subject: [PATCH] Update README.md --- README.md | 44 +++++++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index c653c50..62b66c2 100644 --- a/README.md +++ b/README.md @@ -88,24 +88,46 @@ nvm is a version manager for [node.js](https://nodejs.org/en/), designed to be i ## Installing and Updating -### Install & Update Script - -To **install** or **update** nvm, you should run the [install script][2]. To do that, you may either download and run the script manually, or use the following cURL or Wget command: +### Install NVM on macOS +Change the ownership of these directories to your user ```sh -curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash +sudo chown -R $(whoami) /usr/local/share/zsh /usr/local/share/zsh/site-functions ``` + +Make sure that user has write permission ```sh -wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash +chmod u+w /usr/local/share/zsh /usr/local/share/zsh/site-functions +``` + +Use Humebrew to install NVM +```sh +brew install nvm +``` + +Create a director for NVM in home +```sh +mkdir ~/.nvm +``` + +Configure Required Environment Variable +```sh +vim ~/.bash_profile +``` + +Add the following lines to ~/.bash_profile +```sh +export NVM_DIR=~/.nvm +source $(brew --prefix nvm)/nvm.sh +``` +Press ESC +:wq to save and close the file. + +Load the variable to the current shell environment +```sh +source ~/.bash_profile ``` Running either of the above commands downloads a script and runs it. The script clones the nvm repository to `~/.nvm`, and attempts to add the source lines from the snippet below to the correct profile file (`~/.bash_profile`, `~/.zshrc`, `~/.profile`, or `~/.bashrc`). - -```sh -export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" -[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm -``` - #### Additional Notes - If the environment variable `$XDG_CONFIG_HOME` is present, it will place the `nvm` files there.