ウェブサイト検索

RHEL および Debian システムに Node.js と NPM をインストールする方法


このガイドでは、CentOS、Fedora、Rocky、AlmaLinux などの RHEL ベースのディストリビューションに最新バージョンの NodejsNPM をインストールする方法を説明します。 Ubuntu や Linux Mint などの Debian ベースのディストリビューション。

Nodejs は、Chrome の V8 JavaScript エンジンに基づいて構築された軽量で効率的な JavaScript プラットフォームであり、NPM はデフォルトの NodeJS パッケージ マネージャーです。これを使用して、スケーラブルなネットワーク アプリケーションを構築できます。

このページでは:
  • RHEL ベースのディストリビューションに Node.js をインストールする方法
  • Debian、Ubuntu、Linux Mint に Node.js をインストールする方法

RHEL ディストリビューションに Node.js をインストールする方法

最新バージョンの Node.jsNPM は、Nodejs Web サイトによって管理されている公式の NodeSource Enterprise Linux リポジトリから入手できます。最新のNodejs および NPM パッケージをインストールできるようにするには、システムに追加する必要があります。

重要: RHEL 6 または CentOS 6 の古いリリースを実行している場合は、以下をお読みください。古いディストリビューションでの Node.js の実行について。

RHEL、CentOS、Fedora、Rocky、Alma への NodeJS のインストール

最新バージョンの Node.js のリポジトリを追加するには、root または非 root で次のコマンドを使用します。

------------- For Node.js v19.x ------------- 
curl -fsSL https://rpm.nodesource.com/setup_19.x | sudo bash -
sudo yum install -y nodejs

------------- For Node.js v18.x ------------- 
curl -fsSL https://rpm.nodesource.com/setup_18.x | sudo bash -
sudo yum install -y nodejs

------------- For Node.js v16.x ------------- 
curl -fsSL https://rpm.nodesource.com/setup_16.x | sudo bash -
sudo yum install -y nodejs

------------- For Node.js v14.x ------------- 
curl -fsSL https://rpm.nodesource.com/setup_14.x | sudo bash -
sudo yum install -y nodejs

オプション: システムに必要なgcc-c++make などの開発ツールがあります。 、npm からネイティブ アドオンを構築するため。

yum install gcc-c++ make
OR
yum groupinstall 'Development Tools'

Debian、Ubuntu、Linux Mint に Node.js をインストールする方法

最新バージョンの Node.jsNPM は、Nodejs Web サイトによって管理されている公式 NodeSource Enterprise Linux リポジトリからも入手できます。システムに最新の Nodejs および NPM パッケージをインストールできるようにします。

Ubuntu と Mint に Node.js をインストールする

------------- For Node.js v19.x ------------- 
curl -fsSL https://deb.nodesource.com/setup_19.x | sudo -E bash - &&\
sudo apt-get install -y nodejs

------------- For Node.js v18.x -------------
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - &&\
sudo apt-get install -y nodejs

------------- For Node.js v16.x -------------
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash - &&\
sudo apt-get install -y nodejs

------------- For Node.js v14.x -------------
curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash - &&\
sudo apt-get install -y nodejs

Debian に Node.js をインストールする

------------- For Node.js v19.x ------------- 
curl -fsSL https://deb.nodesource.com/setup_19.x | bash - &&\
sudo apt-get install -y nodejs

------------- For Node.js v18.x ------------- 
curl -fsSL https://deb.nodesource.com/setup_18.x | bash - &&\
sudo apt-get install -y nodejs

------------- For Node.js v16.x ------------- 
curl -fsSL https://deb.nodesource.com/setup_16.x | bash - &&\
sudo apt-get install -y nodejs

------------- For Node.js v14.x ------------- 
curl -fsSL https://deb.nodesource.com/setup_14.x | bash - &&\
sudo apt-get install -y nodejs

オプション: システムに必要なgcc-c++make などの開発ツールがあります。 、npm からネイティブ アドオンを構築するため。

sudo apt-get install -y build-essential

Linux での最新の Nodejs と NPM のテスト

nodejsNPM の簡単なテストを行うには、次のコマンドを使用してシステムにインストールされているバージョンを確認するだけです。

RHEL ベースのシステムの場合

node --version
npm --version

Debian、Ubuntu、および Linux Mint の場合

nodejs --version
npm --version

これで、NodejsNPM がインストールされ、システムで使用できるようになりました。

これらは簡単で簡単な手順だったと思いますが、問題が発生した場合は、私たちに知らせていただければ、私たちがあなたを助ける方法を見つけます。このガイドがお役に立てば幸いです。常に Tecmint とのつながりを保つことを忘れないでください。