Mac uses nvm to manage node version switching

Install

  1. Use npm to install n globally (since you need to write files, you use sudo to elevate the operation and use administrator privileges to execute the command)
    sudo npm i -g n
  2. After the progress bar runs out, check whether the installation is complete.
    n -V

Install and switch node versions

  1. List all node versions
    n ls
  2. install a version
    sudo n xx.xx.x (xx.xx.x 为要安装的版本号)
    Insert image description here
  3. Install the latest versionsudo n lastest
  4. Install the latest stable versionsudo n stable
    Insert image description here
  5. Switch the node version (enter the command and select the up and down keyboard to confirm)
    n
  6. Delete a versionn rm xx.xx.x
  7. Use a version to run the scriptn use xx.xx.x a.js

Guess you like

Origin blog.csdn.net/weixin_57541715/article/details/131124160