npm-git-install
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesenpm install Git Repository Guide
npm 安装Git仓库指南
GitHub 리포지토리에서 직접 npm 패키지를 설치하는 방법을 다룹니다. npm 레지스트리에 없는 패키지, 특정 브랜치, 프라이빗 리포지토리 설치에 유용합니다.
本文介绍如何直接从GitHub仓库安装npm包。适用于安装npm注册表中没有的包、特定分支的包以及私有仓库的包。
When to use this skill
何时使用该方法
- npm에 없는 패키지: 아직 퍼블리시되지 않은 패키지 설치
- 특정 브랜치/태그: main, develop, 특정 릴리스 태그 설치
- 프라이빗 리포지토리: 조직 내부 패키지 설치
- 포크된 패키지: 수정된 포크 버전 사용
- 최신 커밋 테스트: 릴리스 전 최신 코드 테스트
- npm中没有的包:安装尚未发布的包
- 特定分支/标签:安装main、develop分支或特定发布标签的包
- 私有仓库:安装组织内部的包
- 复刻的包:使用修改后的复刻版本
- 测试最新提交:在发布前测试最新代码
1. 설치 명령어
1. 安装命令
기본 문법
基本语法
bash
npm install git+https://github.com/<owner>/<repo>.git#<branch|tag|commit>bash
npm install git+https://github.com/<owner>/<repo>.git#<branch|tag|commit>HTTPS 방식 (일반적)
HTTPS方式(常用)
bash
undefinedbash
undefined특정 브랜치
特定分支
npm install -g git+https://github.com/JEO-tech-ai/supercode.git#main
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#v1.0.0
특정 커밋
特定提交
npm install git+https://github.com/owner/repo.git#abc1234
npm install git+https://github.com/owner/repo.git#abc1234
기본 브랜치 (# 생략 시)
默认分支(省略#时)
npm install git+https://github.com/owner/repo.git
undefinednpm install git+https://github.com/owner/repo.git
undefinedSSH 방식 (SSH 키 설정된 경우)
SSH方式(已配置SSH密钥时)
bash
npm install -g git+ssh://git@github.com:JEO-tech-ai/supercode.git#mainbash
npm install -g git+ssh://git@github.com:JEO-tech-ai/supercode.git#main상세 로그 보기
查看详细日志
bash
npm install -g git+https://github.com/JEO-tech-ai/supercode.git#main --verbosebash
npm install -g git+https://github.com/JEO-tech-ai/supercode.git#main --verbose2. npm install 플로우
2. npm install流程
Git URL로 설치할 때 npm이 수행하는 과정:
1. Git Clone
└─ 지정된 브랜치(#main)의 리포지토리 복제
↓
2. 의존성 설치
└─ package.json의 dependencies 설치
↓
3. Prepare 스크립트 실행
└─ "prepare" 스크립트 실행 (TypeScript 컴파일, 빌드 등)
↓
4. 글로벌 바이너리 등록
└─ bin 필드의 실행 파일을 글로벌 경로에 링크使用Git URL安装时npm执行的步骤:
1. Git克隆
└─ 克隆指定分支(#main)的仓库
↓
2. 安装依赖
└─ 安装package.json中的dependencies依赖
↓
3. 执行Prepare脚本
└─ 执行"prepare"脚本(如TypeScript编译、构建等)
↓
4. 注册全局二进制文件
└─ 将bin字段中的可执行文件链接到全局路径내부 동작
内部操作
bash
undefinedbash
undefinednpm이 내부적으로 수행하는 작업
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
---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
---3. 설치 위치 확인
3. 查看安装位置
bash
undefinedbash
undefined글로벌 npm 경로 확인
查看全局npm路径
npm root -g
npm root -g
macOS/Linux: /usr/local/lib/node_modules
macOS/Linux: /usr/local/lib/node_modules
Windows: C:\Users<username>\AppData\Roaming\npm\node_modules
Windows: C:\Users<username>\AppData\Roaming\npm\node_modules
설치된 패키지 확인
查看已安装的包
npm list -g <package-name>
npm list -g <package-name>
바이너리 위치 확인
查看二进制文件位置
which <command>
which <command>
또는
或者
npm bin -g
undefinednpm bin -g
undefined플랫폼별 설치 위치
各平台安装位置
| 플랫폼 | 패키지 위치 | 바이너리 위치 |
|---|---|---|
| macOS/Linux | | |
| Windows | | |
| nvm (macOS) | | |
| 平台 | 包位置 | 二进制文件位置 |
|---|---|---|
| macOS/Linux | | |
| Windows | | |
| nvm (macOS) | | |
4. package.json에 의존성 추가
4. 在package.json中添加依赖
dependencies에 Git URL 사용
在dependencies中使用Git URL
json
{
"dependencies": {
"supercode": "git+https://github.com/JEO-tech-ai/supercode.git#main",
"my-package": "git+ssh://git@github.com:owner/repo.git#v1.0.0",
"another-pkg": "github:owner/repo#branch"
}
}json
{
"dependencies": {
"supercode": "git+https://github.com/JEO-tech-ai/supercode.git#main",
"my-package": "git+ssh://git@github.com:owner/repo.git#v1.0.0",
"another-pkg": "github:owner/repo#branch"
}
}단축 문법
简写语法
json
{
"dependencies": {
"pkg1": "github:owner/repo",
"pkg2": "github:owner/repo#branch",
"pkg3": "github:owner/repo#v1.0.0",
"pkg4": "github:owner/repo#commit-sha"
}
}json
{
"dependencies": {
"pkg1": "github:owner/repo",
"pkg2": "github:owner/repo#branch",
"pkg3": "github:owner/repo#v1.0.0",
"pkg4": "github:owner/repo#commit-sha"
}
}5. 프라이빗 리포지토리 설치
5. 安装私有仓库包
SSH 키 방식 (권장)
SSH密钥方式(推荐)
bash
undefinedbash
undefined1. SSH 키 생성
1. 生成SSH密钥
ssh-keygen -t ed25519 -C "your_email@example.com"
ssh-keygen -t ed25519 -C "your_email@example.com"
2. GitHub에 공개키 등록
2. 在GitHub上注册公钥
cat ~/.ssh/id_ed25519.pub
cat ~/.ssh/id_ed25519.pub
GitHub → Settings → SSH Keys → New SSH Key
GitHub → 设置 → SSH密钥 → 新建SSH密钥
3. SSH 방식으로 설치
3. 使用SSH方式安装
npm install git+ssh://git@github.com:owner/private-repo.git
undefinednpm install git+ssh://git@github.com:owner/private-repo.git
undefinedPersonal Access Token 방식
个人访问令牌(PAT)方式
bash
undefinedbash
undefined1. GitHub에서 PAT 생성
1. 在GitHub上生成PAT
GitHub → Settings → Developer settings → Personal access tokens
GitHub → 设置 → 开发者设置 → 个人访问令牌
2. 토큰 포함 URL로 설치
2. 使用包含令牌的URL安装
npm install git+https://<token>@github.com/owner/private-repo.git
npm install git+https://<token>@github.com/owner/private-repo.git
3. 환경변수 사용 (보안 권장)
3. 使用环境变量(推荐安全做法)
export GITHUB_TOKEN=ghp_xxxxxxxxxxxx
npm install git+https://${GITHUB_TOKEN}@github.com/owner/private-repo.git
undefinedexport GITHUB_TOKEN=ghp_xxxxxxxxxxxx
npm install git+https://${GITHUB_TOKEN}@github.com/owner/private-repo.git
undefined.npmrc 설정
.npmrc配置
bash
undefinedbash
undefined~/.npmrc
~/.npmrc
//github.com/:_authToken=${GITHUB_TOKEN}
---//github.com/:_authToken=${GITHUB_TOKEN}
---6. 자주 발생하는 오류 & 해결
6. 常见错误与解决方法
Permission denied (EACCES)
权限拒绝(EACCES)
bash
undefinedbash
undefined방법 1: 소유권 변경
方法1:修改所有权
sudo chown -R $(whoami) /usr/local/lib/node_modules
sudo chown -R $(whoami) /usr/local/lib/node_modules
방법 2: npm 디렉토리 변경 (권장)
方法2:修改npm目录(推荐)
mkdir /.npm-global
npm config set prefix '/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
undefinedmkdir /.npm-global
npm config set prefix '/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
undefinedGit이 설치되지 않음
未安装Git
bash
undefinedbash
undefinedmacOS
macOS
brew install git
brew install git
Ubuntu/Debian
Ubuntu/Debian
sudo apt-get install git
sudo apt-get install git
Windows
Windows
undefinedundefinedGitHub 인증 오류
GitHub认证错误
bash
undefinedbash
undefinedSSH 연결 테스트
测试SSH连接
ssh -T git@github.com
ssh -T git@github.com
인증 정보 캐시
缓存认证信息
git config --global credential.helper store
git config --global credential.helper store
또는 macOS
或者macOS
git config --global credential.helper osxkeychain
undefinedgit config --global credential.helper osxkeychain
undefinedprepare 스크립트 실패
Prepare脚本执行失败
bash
undefinedbash
undefinedTypeScript 프로젝트인 경우
如果是TypeScript项目
npm install -g typescript
npm install -g typescript
빌드 실패 시 상세 로그
构建失败时查看详细日志
npm install git+https://... --verbose 2>&1 | tee npm-install.log
undefinednpm install git+https://... --verbose 2>&1 | tee npm-install.log
undefined캐시 문제
缓存问题
bash
undefinedbash
undefinednpm 캐시 삭제
清除npm缓存
npm cache clean --force
npm cache clean --force
재설치
重新安装
npm uninstall -g <package>
npm install -g git+https://...
---npm uninstall -g <package>
npm install -g git+https://...
---7. 업데이트 & 관리
7. 更新与管理
업데이트
更新
bash
undefinedbash
undefined최신 버전으로 업데이트 (재설치)
更新到最新版本(重新安装)
npm uninstall -g <package>
npm install -g git+https://github.com/owner/repo.git#main
npm uninstall -g <package>
npm install -g git+https://github.com/owner/repo.git#main
package.json 의존성 업데이트
更新package.json中的依赖
npm update <package>
undefinednpm update <package>
undefined버전 확인
查看版本
bash
undefinedbash
undefined설치된 버전 확인
查看已安装版本
npm list -g <package>
npm list -g <package>
원격 최신 커밋 확인
查看远程最新提交
git ls-remote https://github.com/owner/repo.git HEAD
undefinedgit ls-remote https://github.com/owner/repo.git HEAD
undefined제거
卸载
bash
npm uninstall -g <package>bash
npm uninstall -g <package>8. Cursor/VS Code 확장 통합 예시
8. Cursor/VS Code扩展集成示例
Supercode 설치 예시
Supercode安装示例
bash
undefinedbash
undefined글로벌 설치
全局安装
npm install -g git+https://github.com/JEO-tech-ai/supercode.git#main
npm install -g git+https://github.com/JEO-tech-ai/supercode.git#main
설치 확인
查看安装版本
supercode --version
undefinedsupercode --version
undefined프로젝트 설정 파일
项目配置文件
json
// .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"
}
}json
// .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"
}
}9. Best Practices
9. 最佳实践
DO (권장)
推荐做法
- 특정 버전/태그 사용: 형태로 버전 고정
#v1.0.0 - SSH 방식 선호: 프라이빗 리포 접근 시 SSH 키 사용
- 환경변수로 토큰 관리: PAT는 환경변수로 관리
- lockfile 커밋: package-lock.json 커밋으로 재현성 확보
- verbose 옵션 활용: 문제 발생 시 상세 로그 확인
- 使用特定版本/标签:以形式固定版本
#v1.0.0 - 优先使用SSH方式:访问私有仓库时使用SSH密钥
- 用环境变量管理令牌:通过环境变量管理PAT
- 提交lockfile:提交package-lock.json确保可重现性
- 使用verbose选项:出现问题时查看详细日志
DON'T (금지)
禁止做法
- 토큰 하드코딩: package.json에 토큰 직접 입력 금지
- 최신 커밋 의존: 프로덕션에서 대신 태그 사용
#main - sudo 남용: 권한 문제는 디렉토리 설정으로 해결
- 캐시 무시: 이상 동작 시 캐시 클리어 필수
- 硬编码令牌:禁止在package.json中直接输入令牌
- 依赖最新提交:生产环境中使用标签而非
#main - 滥用sudo:通过目录设置解决权限问题
- 忽略缓存:出现异常时必须清除缓存
Constraints
约束条件
필수 규칙 (MUST)
必须遵守的规则
- Git 설치 필수: npm git URL 설치 전 git 설치 확인
- 네트워크 접근: GitHub에 접근 가능한 환경 필요
- Node.js 버전: package.json의 engines 필드 확인
- 必须安装Git:使用npm Git URL安装前需确认已安装Git
- 网络访问:需要能访问GitHub的环境
- Node.js版本:确认符合package.json中engines字段的要求
금지 사항 (MUST NOT)
禁止事项
- 인증 토큰 노출: 로그, 코드에 토큰 노출 금지
- 무분별한 sudo: 권한 문제는 설정으로 해결
- 프로덕션에서 #main: 특정 버전/태그로 고정
- 暴露认证令牌:禁止在日志、代码中暴露令牌
- 滥用sudo:通过配置解决权限问题
- 生产环境使用#main:必须固定到特定版本/标签
References
参考资料
Metadata
元数据
버전
版本
- 현재 버전: 1.0.0
- 최종 업데이트: 2026-01-10
- 호환 플랫폼: Claude, ChatGPT, Gemini, Opencode
- 当前版本:1.0.0
- 最后更新:2026-01-10
- 兼容平台:Claude, ChatGPT, Gemini, Opencode
관련 스킬
相关技能
- environment-setup
- git-workflow
- environment-setup
- git-workflow
태그
标签
#npm#git#github#install#package-management#node#npm#git#github#install#package-management#node