#NVM #NodeVersionManager #NodeJS
#JavaScript #WebDevelopment #Coding
#Programming #DevTools #SoftwareDevelopment
#TechTutorial #FrontendDevelopment #BackendDevelopment
#FullStackDevelopment #WebDev
#CodeTips #TechGuide #LearnToCode #TechEducation
#DeveloperTools #NPM
What is NVM:
Node Version Manager (NVM) is a tool that allows developers to manage multiple versions of Node.js on their local machine. It simplifies the process of switching between different versions of Node.js, which can be particularly useful when working on multiple projects that require different Node.js environments. Below, we’ll go into detail on how to install, use, and manage Node.js versions with NVM.
Features of NVM
Install Multiple Versions of Node.js: NVM allows you to install multiple versions of Node.js on your machine.
Switch Between Versions: Easily switch between different versions of Node.js for different projects.
Global Packages Management: Each Node.js version has its own set of global packages.
Custom Aliases: Create aliases for specific Node.js versions.
Cross-Platform: Works on Unix-based systems (Linux, macOS) and Windows (via nvm-windows).
Installation
Unix-based Systems (Linux, macOS)
Using cURL:
curl o https://raw.githubusercontent.com/nvm... | bash
Using Wget:
wget qO https://raw.githubusercontent.com/nvm... | bash
Load NVM:
source ~/.nvm/nvm.sh
Add NVM to Shell Startup File:
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
Windows
Download the Installer:
Go to the nvm-windows releases page.
Download the nvm-setup.zip file from the latest release.
Run the Installer:
Extract the downloaded nvm-setup.zip file.
Run the nvm-setup.exe installer and follow the setup instructions.
Open Command Prompt or PowerShell and verify the installation:
nvm version
Using NVM
Basic Commands
Install a Specific Node.js Version:
nvm install [version]
Example: nvm install 14.17.0
Use a Specific Node.js Version:
nvm use [version]
Example: nvm use 14.17.0
List Installed Versions:
nvm ls
List Available Versions for Installation:
nvm ls-remote
Set a Default Node.js Version:
nvm alias default [version]
Example: nvm alias default 14.17.0
Uninstall a Node.js Version:
nvm uninstall [version]
Example: nvm uninstall 14.17.0
Advanced Usage
Create Aliases for Versions:
nvm alias [alias] [version]
Example: nvm alias default 14.17.0
Switch to the Default Version:
nvm use default
Run Node with a Specific Version Without Switching:
nvm run [version] [node_file]
Example: nvm run 14.17.0 app.js
Check Node.js and npm Version:
node -v
npm -v
Reinstall npm for a Specific Node.js Version:
nvm install-latest-npm
List Aliases:
nvm alias
Practical Example Workflow
Install the Latest Version of Node.js:
nvm install node
Install a Specific Version of Node.js:
nvm install 16.3.0
Switch to the Newly Installed Version:
nvm use 16.3.0
Set a Default Version:
nvm alias default 16.3.0
Verify the Node.js Version:
node -v
Benefits of Using NVM
Flexibility: Easily switch between different Node.js versions for different projects.
Isolation: Each version of Node.js has its own set of global packages, preventing conflicts.
Simplicity: NVM provides a straightforward command-line interface to manage Node.js versions.
By following these steps and utilizing NVM's powerful features, you can efficiently manage multiple Node.js environments, making your development workflow more flexible and organized.
Watch video What is NVM (Node Version Manager) - #5 online without registration, duration hours minute second in high quality. This video was added by user Everyday Be Coding 14 June 2024, don't forget to share it with your friends and acquaintances, it has been viewed on our site 187 once and liked it 1 people.