亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Table of Contents
Step-by-step:
2. Using the DNF Package Manager (CentOS 8 or Stream)
Install from AppStream:
3. Install npm Packages Globally Without Sudo
Final Notes
Home Operation and Maintenance CentOS How to install Node.js on CentOS

How to install Node.js on CentOS

Jul 26, 2025 am 01:31 AM

Installing Node.js on CentOS can be implemented in a variety of ways, depending on the system version and the required Node.js version. 1. Use NodeSource repository (recommended): Suitable for users who need a specific or latest version, first update the system sudo yum update -y, then download the NodeSource installation script corresponding to Node.js 20 or 18 through the curl command and execute it. Then install Node.js and npm, and verify that the installation is successful through node --version and npm --version. 2. Use DNF package manager (applicable to CentOS 8 and above): You can install directly from the AppStream repository. First view the available module list sudo dnf module list nodejs, then select to install nodejs:20 or nodejs:18 versions, and finally verify the installation. 3. Configure the global installation of npm package without sudo: To avoid permission problems, create the ~/.npm-global directory, configure the npm prefix npm config set prefix '~/.npm-global', add ~/.npm-global/bin to the PATH environment variable and overload the configuration. After that, you can use npm install -g to install the global package without sudo permissions. It is recommended that the production environment prioritize the NodeSource method to obtain updated versions. The development environment can consider nvm for multi-version management. All methods need to confirm the installation results through node -v and npm -v. The final choice should be determined based on the CentOS version and actual requirements.

How to install Node.js on CentOS

Installing Node.js on CentOS is straightforward, but the method you choose depends on your version of CentOS and whether you need a specific Node.js version. Here are the most reliable ways to do it.

How to install Node.js on CentOS

1. Using NodeSource Repository (Recommended)

The NodeSource repository provides up-to-date versions of Node.js for CentOS, including LTS and current releases.

Step-by-step:

  1. Update your system

    How to install Node.js on CentOS
     sudo yum update -y
  2. Install the NodeSource setup script

    Go to the NodeSource download page to find the correct command for your desired version.

    How to install Node.js on CentOS

    For Node.js 20 (LTS) :

     curl -fsSL https://rpm.nodesource.com/setup_20.x | sudo bash -

    For Node.js 18 (older LTS) :

     curl -fsSL https://rpm.nodesource.com/setup_18.x | sudo bash -

    This script adds the NodeSource repo and sets up the required signing keys.

  3. Install Node.js and npm

     sudo yum install -y nodejs
  4. Verify installation

     node --version
    npm --version

    You should see output like v20.15.1 and 10.9.0 , depending on the version.


2. Using the DNF Package Manager (CentOS 8 or Stream)

If you're on CentOS 8, CentOS Stream, or a newer variant using dnf , you can install Node.js directly from the AppStream repository.

Install from AppStream:

 sudo dnf module list nodejs

This shows available Node.js versions. To install the default (usually LTS):

 sudo dnf module install nodejs:20

Or for version 18:

 sudo dnf module install nodejs:18

Then verify:

 node --version
npm --version

Note: This method is simpler but may not always have the latest versions.


3. Install npm Packages Globally Without Sudo

After installing Node.js, you might get permission errors when installing global packages. To fix this:

  1. Create a directory for global packages:

     mkdir ~/.npm-global
  2. Configure npm to use it:

     npm config set prefix '~/.npm-global'
  3. Add the directory to your PATH in ~/.bashrc or ~/.bash_profile :

     export PATH=~/.npm-global/bin:$PATH
  4. Reload your shell:

     source ~/.bashrc

Now you can install global packages without sudo :

 npm install -g yarn

Final Notes

  • Use NodeSource if you need the latest or a specific version.
  • Use DNF/AppStream for quick, stable installs on CentOS 8.
  • Always verify with node -v and npm -v .
  • Consider using nvm (Node Version Manager) if you need to switch between multiple Node.js versions frequently (especially for development).

Basically, pick the method that fits your CentOS version and requirements. NodeSource is usually the best bet for production setups needing newer versions.

The above is the detailed content of How to install Node.js on CentOS. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to update the kernel on CentOS? How to update the kernel on CentOS? Jul 02, 2025 am 12:30 AM

The key to updating the CentOS kernel is to use the ELRepo repository and set up the startup items correctly. 1. First run uname-r to view the current kernel version; 2. Install the ELRepo repository and import the key; 3. Use yum to install kernel-lt (long-term support version) or kernel-ml (main version); 4. After the installation is completed, check the available kernels through the awk command and use grub2-set-default to set the default startup item; 5. Generate a new GRUB configuration file grub2-mkconfig-o/boot/grub2/grub.cfg; 6. Finally restart the system and run uname-r again to confirm whether the kernel version is effective. The whole process requires

How to configure a static IP address on CentOS 7 using ifcfg files? How to configure a static IP address on CentOS 7 using ifcfg files? Jul 02, 2025 am 12:22 AM

To configure the CentOS7 static IP address, you need to edit the ifcfg file of the corresponding network card. 1. First confirm the network card name such as ens33 through iplinkshow or ls/sys/class/net; 2. Edit the /etc/sysconfig/network-scripts/ifcfg-ens33 file to set BOOTPROTO=static and fill in IPADDR, NETMASK, GATEWAY and other parameters; 3. After saving, restart the network service to make the configuration take effect; 4. Use the ipaddrshow and ping commands to verify whether the configuration is successful. Be careful to avoid IP conflicts and restart the network service after modification. If you use NetworkM

How to add a user to a secondary group? How to add a user to a secondary group? Jul 05, 2025 am 01:52 AM

In Linux system, using the usermod command to add users to the secondary group is: 1. Execute the sudousermod-a-G group name username command to add, where -a means append to avoid overwriting the original secondary group; 2. Use groups username or grep group name /etc/group to verify whether the operation is successful; 3. Note that the modification only takes effect after the user logs in again, and the main group modification should use the -g parameter; 4. You can also manually edit the /etc/group file to add users, but be careful to avoid system abnormalities caused by format errors.

How to migrate from CentOS 8 to AlmaLinux or Rocky Linux? How to migrate from CentOS 8 to AlmaLinux or Rocky Linux? Jul 06, 2025 am 01:12 AM

To migrate from CentOS8 to AlmaLinux or RockyLinux, follow the clear steps. First, choose AlmaLinux (suitable for long-term enterprise support) or RockyLinux (emphasizing exactly the same as RHEL) according to your needs. Secondly, prepare the system environment: update the software package, back up key data, check third-party repositories and disk space. Then, the conversion is automatically completed using the official migration script. RockyLinux needs to clone the repository and run the switch-to-rocky.sh script. AlmaLinux replaces the repository and upgrades with one click through the remote deployment script. Finally, verify system information, clean up residual packets, and update GRUB and ini if ??necessary

How to install a local .rpm file with all dependencies? How to install a local .rpm file with all dependencies? Jul 08, 2025 am 12:51 AM

To correctly install the local RPM file and handle dependencies, you should first use dnf to install it directly, because it can automatically obtain the required dependencies from the configured repository; if the system does not support dnf, you can use yum's localinstall command instead; if the dependency cannot be resolved, you can manually download and install all related packages; finally, you can also forcefully ignore the dependency installation, but this method is not recommended. 1. Use sudodnfinstall./package-name.rpm to automatically resolve dependencies; 2. If there is no dnf, you can use sudoyumlocalinstall./package-name.rpm; 3. Force installation and execute sudorpm-ivh--nod

How to configure a static IP address on CentOS 8/9 using nmcli? How to configure a static IP address on CentOS 8/9 using nmcli? Jul 10, 2025 pm 12:19 PM

How to set a static IP address using nmcli on CentOS8 or 9? 1. First run the nmcliconnectionshow and ipa commands to view the current network interface and its configuration; 2. Use the nmcliconnectionmodify command to modify the connection configuration, specify parameters such as ipv4.methodmanual, ipv4.addresses (such as 192.168.1.100/24), ipv4.gateway (such as 192.168.1.1), and ipv4.dns (such as 8.8.8.8). 3. Run the nmcliconnectiondown and up commands to restart the connection to make the changes take effect, or

What is the minimal install of CentOS and what does it include? What is the minimal install of CentOS and what does it include? Jul 07, 2025 am 12:35 AM

AminimalinstallofCentOSisalightweightsetupthatincludesonlyessentialcomponents,makingitidealforserversorsystemsrequiringfullcontrol.Itcontainscoreutilitieslikebash,yum/dnf,networkingtools,andsecuritypackages,whileexcludingdesktopenvironments,webserver

How to check if SELinux is in enforcing or permissive mode? How to check if SELinux is in enforcing or permissive mode? Jul 04, 2025 am 01:43 AM

The current running mode of SELinux can be viewed through the command line. Use getenforce command to directly display the current status, and the output is Enforcing, Permissive or Disabled; view the /etc/selinux/config file to know the default startup mode; temporarily change the mode can be setenforce1 (enforcing) or setenforce0 (permissive), but restore the configuration file settings after restart; in actual applications, you need to pay attention to service compatibility issues, and switch modes to troubleshoot problems if necessary.

See all articles