[node.js] Use nvm to switch node environment

The steps to use nvm to switch Node.js version are as follows:

1. Installation steps

  1. To uninstall node.js before installation,
    you must uninstall the original node.js. Use the control panel to uninstall or find the corresponding file and delete it. It’s best to check again after deleting. For details, see [node.js] How to ensure node.js is uninstalled cleanly .

  2. Install nvm :
    If you haven’t installed nvm yet, you can install it in the following ways:

    On Linux/macOS, you can use the following command:

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

    On Windows, the latest installer can be downloaded from the nvm-windows GitHub page.
    Releases · coreybutler/nvm-windows · GitHub

  3. Install the required Node.js version
    After installing nvm, use the following command to install the required Node.js version, for example:

    nvm install 14.18.0 
    

    or

    nvm install 16.14.0
    

2. Usage steps

  1. Switch the Node.js version:
    After the installation is complete, use the following command to switch to the Node.js version you need:

    nvm use 14.18.0 
    

    or

    nvm use 16.14.0 
    
  2. Set default version

    If you need to automatically use a specific version every time you start a new terminal, you can set the default version:

    nvm alias default 14.18.0 
    

    or

    nvm alias default 16.14.0 
    

    Then restart the terminal.

  3. Verify Node.js version:
    Use the following command to verify the Node.js version:

     node -v 
    

    Make sure the output version matches your desired version.

With these steps, you should be able to successfully switch Node.js versions using nvm.

3. Common Error Reports

Update next time

Supongo que te gusta

Origin blog.csdn.net/weixin_45188218/article/details/135342553
Recomendado
Clasificación