Skip to content

Linux 에서 fnm 설치

fnm 은 Linux 에서 여러 설치 방법을 제공합니다. 이 가이드는 다양한 Linux 배포판에서 fnm 을 설치하는 데 도움을 드립니다.

설치 방법

curl 스크립트 사용 (권장)

가장 간단한 설치 방법:

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

설치 후 프롬프트에 따라 Shell 을 다시 로드하거나 수동으로 PATH 에 추가:

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

Homebrew 사용

Linux 에 Homebrew 가 설치된 경우:

bash
brew install fnm

수동 다운로드

  1. fnm Releases 페이지 방문
  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
# 방법 1: curl 스크립트 사용
curl -fsSL https://fnm.vercel.app/install | bash

# 방법 2: 수동 설치
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
# 종속성 설치
sudo dnf install -y unzip  # Fedora
# 또는
sudo yum install -y unzip  # CentOS/RHEL

# curl 스크립트 사용
curl -fsSL https://fnm.vercel.app/install | bash

# 또는 수동 설치
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
# AUR 헬퍼 사용
yay -S fnm-bin

# 또는 AUR 에서 빌드
git clone https://aur.archlinux.org/fnm-bin.git
cd fnm-bin
makepkg -si

Alpine Linux

bash
# 종속성 설치
apk add bash curl unzip

# curl 스크립트 사용
curl -fsSL https://fnm.vercel.app/install | bash

# 또는 수동 설치
wget https://github.com/Schniz/fnm/releases/latest/download/fnm-linux.zip
unzip fnm-linux.zip -d ~/.local/bin
chmod +x ~/.local/bin/fnm

Shell 구성

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

Shell 완성

Bash 완성

bash
# bash-completion 설치 (설치되지 않은 경우)
sudo apt install bash-completion  # Debian/Ubuntu
sudo dnf install bash-completion  # Fedora

# 완성 스크립트 추가
fnm completions --shell bash >> ~/.bashrc
source ~/.bashrc

Zsh 완성

bash
# 완성 디렉토리 생성
mkdir -p ~/.zsh/completions

# 완성 스크립트 생성
fnm completions --shell zsh > ~/.zsh/completions/_fnm

# ~/.zshrc 에 추가
fpath=(~/.zsh/completions $fpath)
autoload -U compinit && compinit

Fish 완성

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

중국에서 미러 사용

중국 본토에서는 미러를 구성하여 다운로드 속도를 높이는 것이 권장됩니다:

bash
# Shell 구성 파일에 추가
export FNM_NODE_DIST_MIRROR=https://npmmirror.com/mirrors/node

# 또는 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
화웨이 클라우드https://mirrors.huaweicloud.com/nodejs

설치 확인

bash
# fnm 버전 확인
fnm --version

# Node.js 설치
fnm install --lts

# Node.js 확인
node --version
npm --version

일반적인 문제

Command Not Found

bash
# fnm 이 PATH 에 있는지 확인
which fnm

# 수동으로 PATH 에 추가
export PATH="$HOME/.fnm:$PATH"

# PATH 에 영구히 추가
echo 'export PATH="$HOME/.fnm:$PATH"' >> ~/.bashrc

권한 문제

bash
# fnm 에 실행 권한이 있는지 확인
chmod +x ~/.fnm/fnm
# 또는
chmod +x /usr/local/bin/fnm

다운로드 실패

bash
# 미러 사용
export FNM_NODE_DIST_MIRROR=https://npmmirror.com/mirrors/node
fnm install --lts

다음 단계

설치 후 다음을 수행할 수 있습니다:

관련 링크