Installing Node.js and npm
Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. Node.js' package ecosystem, npm, is the largest ecosystem of open source libraries in the world.
Installing Node.js
For Windows:
-
Download the Installer:
- Navigate to the official Node.js website (opens in a new tab) and download the Windows Installer (.msi) file.
- The installer also includes npm, so there's no need to install npm separately.
-
Begin the Installation:
- Run the .msi file and follow the prompts.
- Accept the license agreement, select the destination for the installation, and choose the components to install.
- Click the Install button to begin the installation.
-
Verify the Installation:
-
Open a command prompt and run the following commands to check the installed versions of Node.js and npm:
node --version npm --version
-
For macOS:
-
Download the Installer:
- Download the macOS installer (.pkg) file from the Node.js website (opens in a new tab).
-
Follow the Installer Prompts:
- Run the installer and follow the prompts to complete the installation.
For Linux (Ubuntu as an example):
-
Install Curl (if not installed):
sudo apt install curl
-
Install Node.js:
-
You can find the installation instructions for your specific Linux distribution on the Node.js’s Binary Distributions page (opens in a new tab).
-
For Ubuntu, run the following commands:
curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash - sudo apt-get install -y nodejs
-
You can replace
setup_14.x
with the setup script for the version of Node.js you wish to install.
-
-
Verify the Installation:
-
Run the following commands to check the installed versions of Node.js and npm:
node --version npm --version
-
Updating npm to the Latest Version:
-
To check the current version of npm, run:
npm -v
-
To update npm to the latest version, run:
npm install -g npm@latest
The commands to check and update npm are the same across Windows, macOS, and Linux.
Additional Recommendations:
- It is advised to use a Node version manager to install Node.js and npm as it can prevent permissions errors when running npm packages globally.
- For more detailed instructions or alternative installation methods, you may refer to the npm Docs (opens in a new tab), freeCodeCamp (opens in a new tab), or Node.js Getting Started Guide (opens in a new tab).
This guide provides a structured way to set up Node.js and npm on different operating systems which are essential for running your Next.js app with TailwindCSS and Next.UI.