Mac (Apple) install nvm for node version control

相信我一般的初学者问题看这一片就够了

error demo

error display

As shown in the figure above, when the version of node does not support some frameworks or components in the current project, this error will generally be reported. When we enter the introduction of this framework according to the error prompt, we will find that it does not support v16 of my current system. .15.0 version, so we need to introduce nvm for node version management (here, let’s not talk nonsense about the definition and functions, just look at the operation)
insert image description here
insert image description here

nvm install

Open the Mac terminal and enter the following command

download command

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

if appearFailed to connect to raw.githubusercontent.com port 443 after 512 ms: Connection refusedIt means that the installation failed. Let’s change the network environment. Of course, if the installation is successful, you can directly see the installation success and skip the following step.
insert image description here

Change network environment

Open the terminal and enter the following commands to modify the environment, press the "i" key on the keyboard to input shell programming, and add the following code as shown in the figure below:
(After completion, click the "esc" key on the upper left corner of the keyboard ": (colon) + wq key" to save and exit the shell

sudo vi /etc/hosts
199.232.68.133 raw.githubusercontent.com

insert image description here

Configure the environment after downloading and installing successfully

Configuration Environment

Enter the following command to change the environment

vi .bash_profile
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

insert image description here

Save and refresh the configuration after exiting the shell

source .bash_profile

The nvm configuration and installation is successful. Enter nvm -vthe check version and the version number appears to complete.

nvm -v

insert image description here

The following are some commonly used nvm commands

  • nvm ls : print out all versions
  • nvm install stable: install the most stable version
  • nvm install v14.15.0 : Install the 14.15.0 version of node
  • nvm uninstall v16.15.0 : delete the 16.15.0 version of node
  • nvm current : the currently used node version
  • nvm use v14.15.0 : change node to version 14.15.0
  • nvm alias default 14.15.0: Set the default node version to 14.15.0

Supongo que te gusta

Origin blog.csdn.net/weixin_45696320/article/details/130672972
Recomendado
Clasificación