Node.js and npm in Linux: Essential Tools for JavaScript Developers
JavaScript is a widely used programming language that can run in the browser or on the server side. To run JavaScript on the server side, you need a JavaScript runtime environment, and Node.js is the most popular one. Node.js is built on Chrome's V8 engine, which lets you write high-performance, event-driven, asynchronous web applications using JavaScript. npm is the default package manager for Node.js, which allows you to easily install, update, and remove various JavaScript modules and packages.
In this article, we will teach you how to install the latest Node.js and npm in Linux, and how to use them to create and run your JavaScript applications. We'll cover three different installation methods: using apt to install nodejs packages from Ubuntu's default repository; using apt to install a specific version of nodejs package from an alternative PPA repository; installing nvm, the Node version manager, and using it to install and manage multiple versions of Node.js. Depending on your needs and preferences, you can choose one of these methods to start your JavaScript development journey.
Nodejs is a lightweight and efficient JavaScript platform built on Chrome's V8 JavaScript engine, and NPM is the default NodeJS package manager. You can use it to build scalable web applications.
This article will introduce:
- How to install Node.js 14 in CentOS, RHEL and Fedora
- How to install Node.js 14 in Debian, Ubuntu and Linux Mint
How to install Node.js 14 in CentOS, RHEL and Fedora
The latest versions of Node.js and NPM are available from the official NodeSource Enterprise Linux repository, which is maintained by the Nodejs website and you need to add it to your system to install the latest Nodejs and NPM packages.
IMPORTANT: If you are running RHEL 6 or an older version of CentOS 6, you may want to read about running Node.js on older distributions.
Installing NodeJS 14.x in RHEL, CentOS and Fedora
To add a repository for the latest version of Node.js 14.x, use the following command as a superuser or non-superuser.
————– As root user ————–
# curl -sL https://rpm.nodesource.com/setup_14.x | bash –
————– User with root privileges ————–
$ curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash –
Installing NodeJS 12.x on RHEL, CentOS and Fedora
If you want to install NodeJS 12.x, please add the following repository.
————– As root user ————–
# curl -sL https://rpm.nodesource.com/setup_12.x | bash –
————– User with root privileges ————–
$ curl -sL https://rpm.nodesource.com/setup_12.x | sudo bash –
Installing NodeJS 10.x on RHEL, CentOS and Fedora
If you want to install NodeJS 10.x, please add the following repository.
————– As root user ————–
# curl -sL https://rpm.nodesource.com/setup_10.x | bash –
————– User with root privileges ————–
$ curl -sL https://rpm.nodesource.com/setup_10.x | sudo bash –
Next, you can now install Nodejs and NPM on your system using the following commands:
# yum -y install nodejs
or
# dnf -y install nodejs
Optional: There are development tools, such as gcc-c, that you need to have installed on your system in order to build native plugins from npm.
# yum install gcc-c make
or
# yum groupinstall ‘Development Tools’
How to Install Node.js 14 in Debian, Ubuntu and Linux Mint
The latest versions of Node.js and NPM are also available from the official NodeSource Enterprise Linux repository, which is maintained by the Nodejs website and you need to add it to your system to install the latest Nodejs and NPM packages.
Installing NodeJS 14.x in Debian, Ubuntu and Linux Mint
——-On Ubuntu and Linux Mint ——-
sudo apt-get install -y nodejs
——- On Debian ——-
# curl -sL https://deb.nodesource.com/setup_14.x | bash –
# apt-get install -y nodejs
Installing NodeJS 12.x in Debian, Ubuntu and Linux Mint
——-On Ubuntu and Linux Mint ——-
sudo apt-get install -y nodejs
——- On Debian ——-
# curl -sL https://deb.nodesource.com/setup_12.x | bash –
# apt-get install -y nodejs
Installing NodeJS 10.x in Debian, Ubuntu and Linux Mint
——-On Ubuntu and Linux Mint——-
sudo apt-get install -y nodejs
——- On Debian ——-
# curl -sL https://deb.nodesource.com/setup_10.x | bash –
# apt-get install -y nodejs
Optional: There are development tools, such as gcc-c, that you need to have installed on your system in order to build native plugins from npm.
$ sudo apt-get install -y build-essential
Testing the latest Node.js and NPM in Linux
For a simple test of nodejs and NPM, you can check the version installed on your system using the following command:
On RHEL, CentOS and Fedora
# node –version
# npm –version
On Debian, Ubuntu and Linux Mint
npm –version

That’s it, Nodejs and NPM are now installed and ready to use on your system.
I believe these are simple steps, but if you run into problems, let us know and we'll find a way to help you. I hope you find this guide helpful and always remember to stay connected to linuxmi.com.
The above is the detailed content of Node.js and npm in Linux: Essential Tools for JavaScript Developers. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

vscode built-in terminal is a development tool that allows running commands and scripts within the editor to simplify the development process. How to use vscode terminal: Open the terminal with the shortcut key (Ctrl/Cmd). Enter a command or run the script. Use hotkeys (such as Ctrl L to clear the terminal). Change the working directory (such as the cd command). Advanced features include debug mode, automatic code snippet completion, and interactive command history.

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

The reasons for the installation of VS Code extensions may be: network instability, insufficient permissions, system compatibility issues, VS Code version is too old, antivirus software or firewall interference. By checking network connections, permissions, log files, updating VS Code, disabling security software, and restarting VS Code or computers, you can gradually troubleshoot and resolve issues.

Writing code in Visual Studio Code (VSCode) is simple and easy to use. Just install VSCode, create a project, select a language, create a file, write code, save and run it. The advantages of VSCode include cross-platform, free and open source, powerful features, rich extensions, and lightweight and fast.

VS Code is available on Mac. It has powerful extensions, Git integration, terminal and debugger, and also offers a wealth of setup options. However, for particularly large projects or highly professional development, VS Code may have performance or functional limitations.
