Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md #2817

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 30 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
### Install NVM on macOS
Change the ownership of these directories to your user
```sh
sudo chown -R $(whoami) /usr/local/share/zsh /usr/local/share/zsh/site-functions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

most nvm users don't use zsh.

```

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:
Make sure that user has write permission
```sh
curl -o- 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nobody should EVER use homebrew to install nvm; homebrew-installed nvm is 100% unsupported and discouraged.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for me using macbook pro m1 it's the only way nvm work :(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That shouldn’t be the case; node itself only supports m1 outside of Rosetta on v16+, but nvm itself should work fine.

```sh
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
brew install nvm
```

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`).
Create a director for NVM in home
```sh
mkdir ~/.nvm
```

<a id="profile_snippet"></a>
Configure Required Environment Variable
```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
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`).

#### Additional Notes

- If the environment variable `$XDG_CONFIG_HOME` is present, it will place the `nvm` files there.</sub>
Expand Down