تثبيت fnm على macOS
يتمتع fnm بطرق تثبيت متعددة على macOS. سيوضح هذا الدليل كيفية اختيار الأنسب لك.
طرق التثبيت
باستخدام Homebrew (موصى به)
Homebrew هو أكثر مدير الحزم شعبية على macOS:
bash
# Install fnm
brew install fnmباستخدام سكريبت curl
لا يتطلب مدير حزم، قم بالتثبيت مباشرة:
bash
curl -fsSL https://fnm.vercel.app/install | bashباستخدام MacPorts
إذا كنت تستخدم MacPorts:
bash
port install fnmالتنزيل اليدوي
- قم بزيارة صفحة إصدارات fnm
- قم بتنزيل
fnm-macos.zip(Intel) أوfnm-macos-arm64.zip(Apple Silicon) - قم باستخراج ونقل إلى دليل PATH:
bash
# Apple Silicon (M1/M2/M3)
unzip fnm-macos-arm64.zip
sudo mv fnm /usr/local/bin
# Intel Mac
unzip fnm-macos.zip
sudo mv fnm /usr/local/binتكوين الصدفة
تستخدم macOS Zsh افتراضياً، ولكن تدعم أيضاً Bash و Fish.
Zsh (افتراضي)
قم بتحرير ~/.zshrc:
bash
# Open configuration file
nano ~/.zshrc
# Add the following content
eval "$(fnm env --use-on-cd)"أعد تحميل التكوين:
bash
source ~/.zshrcBash
قم بتحرير ~/.bashrc أو ~/.bash_profile:
bash
# Open configuration file
nano ~/.bash_profile
# Add the following content
eval "$(fnm env --use-on-cd)"أعد تحميل التكوين:
bash
source ~/.bash_profileFish
قم بتحرير ~/.config/fish/config.fish:
fish
# Open configuration file
nano ~/.config/fish/config.fish
# Add the following content
fnm env --use-on-c | sourceأعد تحميل التكوين:
fish
source ~/.config/fish/config.fishاكتمال الصدفة
اكتمال Zsh
bash
# Add completion script
fnm completions --shell zsh > ~/.zsh/completion/_fnm
# Ensure fpath includes completion directory
# Add to ~/.zshrc
fpath=(~/.zsh/completion $fpath)
# Enable completion
autoload -U compinit && compinitأو باستخدام oh-my-zsh:
bash
# Create completion directory
mkdir -p ~/.oh-my-zsh/completions
# Generate completion script
fnm completions --shell zsh > ~/.oh-my-zsh/completions/_fnmاكتمال Bash
bash
# Add completion script
fnm completions --shell bash >> ~/.bashrc
# Reload
source ~/.bashrcاكتمال Fish
bash
# Generate completion script
fnm completions --shell fish > ~/.config/fish/completions/fnm.fish
# Reload
source ~/.config/fish/config.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)"ملاحظات Apple Silicon (M1/M2/M3)
يدعم fnm بشكل كامل Apple Silicon:
- يكشف تلقائياً عن بنية النظام
- يثبت إصدار ARM64 الأصلي من Node.js
- يدعم محاكاة x64 (عبر Rosetta 2)
تثبيت إصدار x64
إذا كنت تحتاج إلى إصدار x64 من Node.js:
bash
# Install x64 architecture Node.js
fnm install 20 --arch=x64التحقق من التثبيت
bash
# Check fnm version
fnm --version
# Install Node.js
fnm install --lts
# Verify Node.js
node --version
npm --versionالمشكلات الشائعة
الأمر غير موجود
إذا لم يتم العثور على أمر fnm بعد التثبيت:
bash
# Check fnm path
which fnm
# If installed via curl, ensure PATH includes
echo $PATH
# Manually add to PATH
export PATH="$HOME/.fnm:$PATH"مشكلات الأذونات
إذا واجهت مشكلات أذونات:
bash
# Ensure directory has correct permissions
chmod +x ~/.fnm/fnmتثبيت Homebrew لا يعمل
bash
# Re-link
brew unlink fnm && brew link fnm
# Check installation
brew list fnmالخطوات التالية
بعد التثبيت، يمكنك:
- تثبيت Node.js - استخدم fnm لتثبيت Node.js
- مرجع الأوامر - تعرف على جميع الأوامر المتاحة
- إدارة الإصدارات - تعرف على إدارة الإصدارات
روابط ذات صلة
- تثبيت fnm - دليل التثبيت العام
- تثبيت Windows - دليل تثبيت Windows
- تثبيت Linux - دليل تثبيت Linux