تثبيت 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التنزيل اليدوي
- قم بزيارة صفحة إصدارات fnm
- قم بتنزيل الأرشيف الخاص ببنية نظامك:
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- قم باستخراج وتثبيت:
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/fnmCentOS / 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/fnmArch 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 -siAlpine 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 ~/.bashrcZsh
قم بتحرير ~/.zshrc:
bash
echo 'eval "$(fnm env --use-on-cd)"' >> ~/.zshrc
source ~/.zshrcFish
قم بتحرير ~/.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 |
|---|---|
| npmmirror | https://npmmirror.com/mirrors/node |
| جامعة تسينغهوا | https://mirrors.tuna.tsinghua.edu.cn/nodejs-release |
| Huawei Cloud | https://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الخطوات التالية
بعد التثبيت، يمكنك:
- تثبيت Node.js - استخدم fnm لتثبيت Node.js
- مرجع الأوامر - تعرف على جميع الأوامر المتاحة
- إدارة الإصدارات - تعرف على إدارة الإصدارات
روابط ذات صلة
- تثبيت fnm - دليل التثبيت العام
- تثبيت Windows - دليل تثبيت Windows
- تثبيت macOS - دليل تثبيت macOS
- إلغاء تثبيت Ubuntu - دليل إلغاء تثبيت Ubuntu