NVM (Node Version Manager) is a popular tool for managing multiple versions of Node.js on a single machine. Here are some important commands for NVM:
Installation Commands
- Install NVM:
 curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
This script installs the latest version of NVM. Replace `v0.
NVM (Node Version Manager) Important Commands
Installation
- Install NVM:
 curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
This command downloads and runs the NVM install script from the NVM GitHub repository.
- Load NVM:
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 is usually added to your shell profile file (~/.bashrc, ~/.zshrc, etc.) to load NVM when you open a new terminal.
Basic Usage
- Check NVM Version:
nvm --version
- List Installed Node Versions:
  nvm ls
- List Available Node Versions: 
 
 nvm ls-remote
 
- Install a Specific Node Version: 
 nvm install <version>
Replace <version> with the desired version number, e.g., nvm install 16.13.0.
- Use a Specific Node Version:
  nvm use <version>
Replace <version> with the installed version number you want to use.
- Set Default Node Version:
nvm alias default <version>
This sets the default Node.js version to be used in new shell sessions.
- Uninstall a Specific Node Version:
nvm uninstall <version>
- Show Current Node Version: 
 
 nvm current
 
- Run Node with a Specific Version: 
 nvm run <version> <script.js>
Replace `<version>` with the Node.js version and `<script.js>` with the script you want to run.
- 
Execute NPM Commands with Specific Node Version: 
 
 nvm exec <version> npm <command>
 For example, nvm exec 14.17.0 npm install.
- 
Reinstall Packages from Current Version: 
 
 nvm reinstall-packages <version>
 This reinstalls global packages from the specified version into the current version. 
- Get Help: 
nvm help
These commands cover the essential functionality of NVM, helping you to manage different Node.js versions efficiently.
 
 
              
 
    
Top comments (0)