139k views
2 votes
How to install node js using terminal

User SDK
by
8.4k points

1 Answer

3 votes

Final answer:

Install Node.js on macOS using 'brew install node', on Linux with 'sudo apt-get install nodejs' and 'npm', and on Windows, download the installer from the Node.js website and verify using 'node -v' and 'npm -v' commands.

Step-by-step explanation:

To install Node.js using the terminal, you can follow these steps depending on your operating system. As an example, we'll use the most common methods for macOS, Linux, and Windows.

macOS and Linux:

1. Open the terminal.

2. Use a package manager like Homebrew for macOS (by running the brew install node command) or apt for Ubuntu-based Linux distributions (with the sudo apt-get install nodejs and sudo apt-get install npm commands).

3. Once the installation is completed, verify it by typing node -v and npm -v to see the installed versions of Node.js and npm respectively.

Windows:

1. For Windows, you can download the Windows Installer directly from the Node.js website and run it.

2. After installation, open Command Prompt and type node -v and npm -v to confirm the installation of Node.js and npm.

Note: Always make sure you're installing the version of Node.js that fits your project requirements.

User Dan Balthaser
by
8.7k points