Posted by
The Code Post
on
- Get link
- X
- Other Apps
Installing Node.js
To install Node.js, follow these steps. The instructions are applicable for both Linux (especially Ubuntu) and Windows operating systems.
Ubuntu (and other Debian-based systems)
-
Update your repository and install necessary packages:
sudo apt updatesudo apt install -y curl software-properties-common -
Add the NodeSource repository:
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash - -
Install Node.js:
sudo apt-get install -y nodejs -
Verify the installation:
node -vnpm -v
Windows
-
Visit the official Node.js website and download the latest version.
-
Run the downloaded installer and follow the steps in the setup wizard.
-
Verify the installation:
node -vnpm -v
MacOS
-
Install using Homebrew:
brew updatebrew install node@16 -
Configure your path:
echo 'export PATH="/usr/local/opt/node@16/bin:$PATH"' >> ~/.zshrcsource ~/.zshrc -
Verify the installation:
node -vnpm -v
Using NVM (Node Version Manager) to Switch to a Specific Node.js Version (16.20)
Switching to Node.js version 16.20.0 using NVM is straightforward. Follow these steps:
- Install NVM if not already installed.
- Install latest Node.js version:
- Or install a specific Node.js version:
- Verify the installation:
- List all installed node versions:
- Use Node.js version 16.20.0:
- Set the default Node.js version:
- Use the latest installedNode.js version when needed:
nvm install node
nvm install 16.20.0
node -v
npm -v
nvm ls
nvm use 16.20.0
nvm alias default 16.20.0
nvm use node
After installing Node.js version 16.20, running the npm -v command should display npm version 8.19.4, as it is compatible with Node.js 16. This is expected, and you can continue using npm version 8.19.4 without issues.
.png)
Comments
Post a Comment