كيفية تثبيت آخر NodeJS و NPM في لينكس

Nodejs وNPM الإصدارات الأحدث على التوزيعات المبنية على RHEL مثل CentOS، Fedora، Rocky & AlmaLinux والتوزيعات المبنية على Debian مثل Ubuntu & Linux Mint.

Nodejs هي منصة JavaScript خفيفة وفعّالة تم بناؤها بناءً على محرك JavaScript V8 الخاص بـ Chrome، وNPM هو مدير حزم NodeJS الافتراضي. يمكنك استخدامه لبناء تطبيقات الشبكة قابلة للتوسيع.

كيفية تثبيت Node.js في توزيعات RHEL

أحدث إصدار من Node.js و NPM متاح من مستودع NodeSource Enterprise Linux الرسمي، والذي يتم الحفاظ عليه من قبل موقع Nodejs وستحتاج إلى إضافته إلى نظامك لتتمكن من تثبيت أحدث حزم Nodejs و NPM.

مهم: إذا كنت تستخدم إصدارًا أقدم من RHEL 6 أو CentOS 6، قد ترغب في قراءة كيفية تشغيل Node.js على توزيعات قديمة.

تثبيت NodeJS في RHEL، CentOS، Fedora، Rocky & Alma

لإضافة المستودع لأحدث إصدار من 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 التي تحتاج إلى تواجدها في نظامك، لتتمكن من بناء إضافات native من npm.

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

كيفية تثبيت Node.js في Debian، Ubuntu، و Linux Mint

أحدث إصدار من Node.js و NPM متاح أيضًا من مستودع NodeSource Enterprise Linux الرسمي، الذي يتم الحفاظ عليه من قبل موقع Nodejs وستحتاج إلى إضافته إلى نظامك لتتمكن من تثبيت أحدث حزم Nodejs و NPM.

تثبيت Node.js على Ubuntu و Mint

------------- 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

تثبيت Node.js على Debian

------------- 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 التي تحتاج إلى وجودها على نظامك، من أجل بناء إضافات Native من npm.

$ sudo apt-get install -y build-essential

اختبار آخر تحديث لـ Nodejs و NPM في Linux

لإجراء اختبار بسيط لـ nodejs و NPM، يمكنك فقط التحقق من الإصدارات المثبتة على نظامك باستخدام الأوامر التالية:

على أنظمة RHEL

# node --version
# npm --version

على Debian و Ubuntu و Linux Mint

$ nodejs --version
$ npm --version
Check NodeJS Version on CentOS

هذا كل شيء، تم تثبيت Nodejs و NPM الآن وهي جاهزة للاستخدام على نظامك.

I believe these were easy and simple steps to follow but in case of problems you faced, you can let us know and we find ways of helping you. I hope this guide was helpful to you and always remember to stay connected to Tecmint.

Source:
https://www.tecmint.com/install-nodejs-npm-in-centos-ubuntu/