Skip to content

تثبيت fnm على Linux

يتمتع fnm بطرق تثبيت متعددة على Linux. سيوضح هذا الدليل كيفية تثبيت fnm على توزيعات Linux المختلفة.

طرق التثبيت

باستخدام سكريبت curl (موصى به)

أبسط طريقة تثبيت:

bash
curl -fsSL https://fnm.vercel.app/install | bash

بعد التثبيت، اتبع المطالبات لإعادة تحميل الصدفة أو أضف يدوياً إلى PATH:

bash
export PATH="$HOME/.fnm:$PATH"
eval "$(fnm env --use-on-cd)"

باستخدام Homebrew

إذا كان لديك Homebrew مثبت على Linux:

bash
brew install fnm

التنزيل اليدوي

  1. قم بزيارة صفحة إصدارات fnm
  2. قم بتنزيل الأرشيف الخاص ببنية نظامك:
bash
# x86_64
wget https://github.com/Schniz/fnm/releases/latest/download/fnm-linux.zip

# ARM64
wget https://github.com/Schniz/fnm/releases/latest/download/fnm-arm64.zip
  1. قم باستخراج وتثبيت:
bash
unzip fnm-linux.zip -d ~/.local/bin
chmod +x ~/.local/bin/fnm

دليل التثبيت حسب التوزيع

Ubuntu / Debian

bash
# Method 1: Using curl script
curl -fsSL https://fnm.vercel.app/install | bash

# Method 2: Manual installation
sudo apt update
sudo apt install -y unzip
wget https://github.com/Schniz/fnm/releases/latest/download/fnm-linux.zip
sudo unzip fnm-linux.zip -d /usr/local/bin
sudo chmod +x /usr/local/bin/fnm

CentOS / RHEL / Fedora

bash
# Install dependencies
sudo dnf install -y unzip  # Fedora
# or
sudo yum install -y unzip  # CentOS/RHEL

# Using curl script
curl -fsSL https://fnm.vercel.app/install | bash

# Or manual installation
wget https://github.com/Schniz/fnm/releases/latest/download/fnm-linux.zip
sudo unzip fnm-linux.zip -d /usr/local/bin
sudo chmod +x /usr/local/bin/fnm

Arch Linux

bash
# Using AUR helper
yay -S fnm-bin

# Or build from AUR
git clone https://aur.archlinux.org/fnm-bin.git
cd fnm-bin
makepkg -si

Alpine Linux

bash
# Install dependencies
apk add bash curl unzip

# Using curl script
curl -fsSL https://fnm.vercel.app/install | bash

# Or manual installation
wget https://github.com/Schniz/fnm/releases/latest/download/fnm-linux.zip
unzip fnm-linux.zip -d ~/.local/bin
chmod +x ~/.local/bin/fnm

تكوين الصدفة

Bash

قم بتحرير ~/.bashrc:

bash
echo 'eval "$(fnm env --use-on-cd)"' >> ~/.bashrc
source ~/.bashrc

Zsh

قم بتحرير ~/.zshrc:

bash
echo 'eval "$(fnm env --use-on-cd)"' >> ~/.zshrc
source ~/.zshrc

Fish

قم بتحرير ~/.config/fish/config.fish:

fish
echo 'fnm env --use-on-c | source' >> ~/.config/fish/config.fish
source ~/.config/fish/config.fish

اكتمال الصدفة

اكتمال Bash

bash
# Install bash-completion (if not installed)
sudo apt install bash-completion  # Debian/Ubuntu
sudo dnf install bash-completion  # Fedora

# Add completion script
fnm completions --shell bash >> ~/.bashrc
source ~/.bashrc

اكتمال Zsh

bash
# Create completion directory
mkdir -p ~/.zsh/completions

# Generate completion script
fnm completions --shell zsh > ~/.zsh/completions/_fnm

# Add to ~/.zshrc
fpath=(~/.zsh/completions $fpath)
autoload -U compinit && compinit

اكتمال Fish

bash
fnm completions --shell fish > ~/.config/fish/completions/fnm.fish

استخدام مرآة في الصين

في البر الرئيسي للصين، يُوصى بتكوين مرآة لتسريع التنزيلات:

bash
# Add to Shell configuration file
export FNM_NODE_DIST_MIRROR=https://npmmirror.com/mirrors/node

# Or specify during eval
eval "$(fnm env --use-on-cd --node-dist-mirror=https://npmmirror.com/mirrors/node)"

المرآات الشائعة:

مصدر المرآةURL
npmmirrorhttps://npmmirror.com/mirrors/node
جامعة تسينغهواhttps://mirrors.tuna.tsinghua.edu.cn/nodejs-release
Huawei Cloudhttps://mirrors.huaweicloud.com/nodejs

التحقق من التثبيت

bash
# Check fnm version
fnm --version

# Install Node.js
fnm install --lts

# Verify Node.js
node --version
npm --version

المشكلات الشائعة

الأمر غير موجود

bash
# Check if fnm is in PATH
which fnm

# Manually add to PATH
export PATH="$HOME/.fnm:$PATH"

# Permanently add to PATH
echo 'export PATH="$HOME/.fnm:$PATH"' >> ~/.bashrc

مشكلات الأذونات

bash
# Ensure fnm has execute permission
chmod +x ~/.fnm/fnm
# or
chmod +x /usr/local/bin/fnm

فشل التنزيل

bash
# Use mirror
export FNM_NODE_DIST_MIRROR=https://npmmirror.com/mirrors/node
fnm install --lts

الخطوات التالية

بعد التثبيت، يمكنك:

روابط ذات صلة