Mac installation nvm stepping on the pit

install nvm

If there is a node environment before installation, it needs to be uninstalled first.
I have installed node before. Before installing nvm, I need to uninstall the old node. For the uninstallation process, please refer to this article Portal

#查看已经安装在全局的模块
npm ls -g --depth=0
#删除全局 node_modules 目录
sudo rm -rf /usr/local/lib/node_modules
#删除 node
sudo rm /usr/local/bin/node
#删除全局 node 模块注册的软链
cd /usr/local/bin && ls -l | grep "../lib/node_modules/" | awk '{print $9}'| xargs rm

The last case of successful installation:
You can refer to the official website to install the official website portal .
1.
sudo curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash If you try to execute it for the first time, if you report an error, you can’t ping raw.githubusercontent.com and you can’t download the files in it.
2. Modify the /etc/host file (after this, you can ping again and find that the ping fails. If it fails, you can refer to the ip provided below Query the website to modify the host file)

127.0.0.1	localhost
255.255.255.255	broadcasthost
::1             localhost
# 这个是修改后的 也是成功安装成功了
185.199.109.133 raw.githubusercontent.com

Execute again sudo curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
If it fails, check whether you are executing sudo, or execute it again.
If the following display is displayed, it means that the execution is successful.

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 14926  100 14926    0     0  15580      0 --:--:-- --:--:-- --:--:-- 15564
=> nvm is already installed in /Users/liuyuanyuan/.nvm, trying to update using git
* (HEAD detached at FETCH_HEAD)
  master
=> Compressing and cleaning up git repository

=> Appending nvm source string to /Users/liuyuanyuan/.bash_profile
=> Appending bash_completion source string to /Users/liuyuanyuan/.bash_profile
=> Close and reopen your terminal to start using nvm or run the following to use it now:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

3. At this time, it means that the installation is successful. nvm -vIf the execution fails, execute the following. source ~/.bash_profile Note that before executing, check whether there is such a file. I have configured other things before, and it is automatically configured for me after downloading, so just source it . If you do not have this file, you need to configure the reference portal yourself

problems encountered

1. Always report an error:
curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to raw.githubusercontent.com:443
Analysis: I can’t connect to the github website. You can modify the /etc/host file for details. Refer to Portal
2. During the error reporting process I also modified the host file and still failed, maybe the ip address is not working.
The last successful case:
Portal.
Try referring to other cases?
Portal 1 , Portal 2 , modify the host file in this nugget article, you can go to the specified website to query the ip, you can take a look, I did not try this if I succeeded

Finally : Mainly because I have been working for a long time after get off work at night, let’s step on the pit, most of the problems encountered are the above error reports, downloading nvm is mainly for the convenience of node management, because the vue project always pulls down other people’s projects because the node version is too high , there is a problem with too low, it is easy to switch versions with nvm

Guess you like

Origin blog.csdn.net/qq_43566782/article/details/129747875