Update README.md

This commit is contained in:
James Li 2022-05-21 18:37:48 -07:00 committed by GitHub
parent ef3b20c21e
commit f4da02f3de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -88,24 +88,46 @@ nvm is a version manager for [node.js](https://nodejs.org/en/), designed to be i
<a id="install-script"></a>
## 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`).
<a id="profile_snippet"></a>
```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.</sub>