Install npm packages directly from GitHub repositories using git URLs. Use when installing packages from private repos, specific branches, or unreleased versions not yet on npm registry.
GitHub 리포지토리에서 직접 npm 패키지를 설치하는 방법을 다룹니다. npm 레지스트리에 없는 패키지, 특정 브랜치, 프라이빗 리포지토리 설치에 유용합니다.
npm install git+https://github.com/<owner>/<repo>.git#<branch|tag|commit>
# 특정 브랜치
npm install -g git+https://github.com/JEO-tech-ai/supercode.git#main
# 특정 태그
npm install git+https://github.com/owner/repo.git#v1.0.0
# 특정 커밋
npm install git+https://github.com/owner/repo.git#abc1234
# 기본 브랜치 (# 생략 시)
npm install git+https://github.com/owner/repo.git
npm install -g git+ssh://[email protected]:JEO-tech-ai/supercode.git#main
npm install -g git+https://github.com/JEO-tech-ai/supercode.git#main --verbose
Git URL로 설치할 때 npm이 수행하는 과정:
1. Git Clone
└─ 지정된 브랜치(#main)의 리포지토리 복제
↓
2. 의존성 설치
└─ package.json의 dependencies 설치
↓
3. Prepare 스크립트 실행
└─ "prepare" 스크립트 실행 (TypeScript 컴파일, 빌드 등)
↓
4. 글로벌 바이너리 등록
└─ bin 필드의 실행 파일을 글로벌 경로에 링크
# npm이 내부적으로 수행하는 작업
git clone https://github.com/owner/repo.git /tmp/npm-xxx
cd /tmp/npm-xxx
git checkout main
npm install
npm run prepare # 있으면 실행
cp -r . /usr/local/lib/node_modules/repo/
ln -s ../lib/node_modules/repo/bin/cli.js /usr/local/bin/repo
# 글로벌 npm 경로 확인
npm root -g
# macOS/Linux: /usr/local/lib/node_modules
# Windows: C:\Users\<username>\AppData\Roaming\npm\node_modules
# 설치된 패키지 확인
npm list -g <package-name>
# 바이너리 위치 확인
which <command>
# 또는
npm bin -g
| 플랫폼 | 패키지 위치 | 바이너리 위치 |
|---|---|---|
| macOS/Linux | /usr/local/lib/node_modules/ | /usr/local/bin/ |
| Windows | %AppData%\npm\node_modules\ | %AppData%\npm\ |
| nvm (macOS) | ~/.nvm/versions/node/vX.X.X/lib/node_modules/ | ~/.nvm/versions/node/vX.X.X/bin/ |
{
"dependencies": {
"supercode": "git+https://github.com/JEO-tech-ai/supercode.git#main",
"my-package": "git+ssh://[email protected]:owner/repo.git#v1.0.0",
"another-pkg": "github:owner/repo#branch"
}
}
{
"dependencies": {
"pkg1": "github:owner/repo",
"pkg2": "github:owner/repo#branch",
"pkg3": "github:owner/repo#v1.0.0",
"pkg4": "github:owner/repo#commit-sha"
}
}
# 1. SSH 키 생성
ssh-keygen -t ed25519 -C "[email protected]"
# 2. GitHub에 공개키 등록
cat ~/.ssh/id_ed25519.pub
# GitHub → Settings → SSH Keys → New SSH Key
# 3. SSH 방식으로 설치
npm install git+ssh://[email protected]:owner/private-repo.git
# 1. GitHub에서 PAT 생성
# GitHub → Settings → Developer settings → Personal access tokens
# 2. 토큰 포함 URL로 설치
npm install git+https://<token>@github.com/owner/private-repo.git
# 3. 환경변수 사용 (보안 권장)
export GITHUB_TOKEN=ghp_xxxxxxxxxxxx
npm install git+https://${GITHUB_TOKEN}@github.com/owner/private-repo.git
# ~/.npmrc
//github.com/:_authToken=${GITHUB_TOKEN}
# 방법 1: 소유권 변경
sudo chown -R $(whoami) /usr/local/lib/node_modules
# 방법 2: npm 디렉토리 변경 (권장)
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
# macOS
brew install git
# Ubuntu/Debian
sudo apt-get install git
# Windows
# https://git-scm.com/download/win
# SSH 연결 테스트
ssh -T [email protected]
# 인증 정보 캐시
git config --global credential.helper store
# 또는 macOS
git config --global credential.helper osxkeychain
# TypeScript 프로젝트인 경우
npm install -g typescript
# 빌드 실패 시 상세 로그
npm install git+https://... --verbose 2>&1 | tee npm-install.log
# npm 캐시 삭제
npm cache clean --force
# 재설치
npm uninstall -g <package>
npm install -g git+https://...
# 최신 버전으로 업데이트 (재설치)
npm uninstall -g <package>
npm install -g git+https://github.com/owner/repo.git#main
# package.json 의존성 업데이트
npm update <package>
# 설치된 버전 확인
npm list -g <package>
# 원격 최신 커밋 확인
git ls-remote https://github.com/owner/repo.git HEAD
npm uninstall -g <package>
# 글로벌 설치
npm install -g git+https://github.com/JEO-tech-ai/supercode.git#main
# 설치 확인
supercode --version
// .supercoderc 또는 supercode.config.json
{
"aiRules": {
"enabled": true,
"techStack": ["TypeScript", "React", "Node.js"]
},
"smartActions": [
{
"name": "Generate Documentation",
"icon": "docs",
"prompt": "Generate comprehensive documentation"
}
],
"architectureMode": {
"enabled": true,
"detailLevel": "detailed"
}
}
#v1.0.0 형태로 버전 고정#main 대신 태그 사용#npm #git #github #install #package-management #node