npm-git-install

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

npm 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
undefined
bash
undefined

특정 브랜치

特定分支

특정 태그

特定标签

특정 커밋

特定提交

기본 브랜치 (# 생략 시)

默认分支(省略#时)

undefined
undefined

SSH 방식 (SSH 키 설정된 경우)

SSH方式(已配置SSH密钥时)

bash
npm install -g git+ssh://git@github.com:JEO-tech-ai/supercode.git#main
bash
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 --verbose

bash
npm install -g git+https://github.com/JEO-tech-ai/supercode.git#main --verbose

2. 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
undefined
bash
undefined

npm이 내부적으로 수행하는 작업

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
undefined
bash
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
undefined
npm bin -g
undefined

플랫폼별 설치 위치

各平台安装位置

플랫폼패키지 위치바이너리 위치
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/

平台包位置二进制文件位置
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/

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
undefined
bash
undefined

1. 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
undefined
npm install git+ssh://git@github.com:owner/private-repo.git
undefined

Personal Access Token 방식

个人访问令牌(PAT)方式

bash
undefined
bash
undefined

1. 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
undefined
export GITHUB_TOKEN=ghp_xxxxxxxxxxxx npm install git+https://${GITHUB_TOKEN}@github.com/owner/private-repo.git
undefined

.npmrc 설정

.npmrc配置

bash
undefined
bash
undefined

~/.npmrc

~/.npmrc

//github.com/:_authToken=${GITHUB_TOKEN}

---
//github.com/:_authToken=${GITHUB_TOKEN}

---

6. 자주 발생하는 오류 & 해결

6. 常见错误与解决方法

Permission denied (EACCES)

权限拒绝(EACCES)

bash
undefined
bash
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
undefined
mkdir /.npm-global npm config set prefix '/.npm-global' echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc source ~/.bashrc
undefined

Git이 설치되지 않음

未安装Git

bash
undefined
bash
undefined

macOS

macOS

brew install git
brew install git

Ubuntu/Debian

Ubuntu/Debian

sudo apt-get install git
sudo apt-get install git

Windows

Windows

undefined
undefined

GitHub 인증 오류

GitHub认证错误

bash
undefined
bash
undefined

SSH 연결 테스트

测试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
undefined
git config --global credential.helper osxkeychain
undefined

prepare 스크립트 실패

Prepare脚本执行失败

bash
undefined
bash
undefined

TypeScript 프로젝트인 경우

如果是TypeScript项目

npm install -g typescript
npm install -g typescript

빌드 실패 시 상세 로그

构建失败时查看详细日志

npm install git+https://... --verbose 2>&1 | tee npm-install.log
undefined
npm install git+https://... --verbose 2>&1 | tee npm-install.log
undefined

캐시 문제

缓存问题

bash
undefined
bash
undefined

npm 캐시 삭제

清除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
undefined
bash
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>
undefined
npm update <package>
undefined

버전 확인

查看版本

bash
undefined
bash
undefined

설치된 버전 확인

查看已安装版本

npm list -g <package>
npm list -g <package>

원격 최신 커밋 확인

查看远程最新提交

undefined
undefined

제거

卸载

bash
npm uninstall -g <package>

bash
npm uninstall -g <package>

8. Cursor/VS Code 확장 통합 예시

8. Cursor/VS Code扩展集成示例

Supercode 설치 예시

Supercode安装示例

bash
undefined
bash
undefined

글로벌 설치

全局安装

설치 확인

查看安装版本

supercode --version
undefined
supercode --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 (권장)

推荐做法

  1. 특정 버전/태그 사용:
    #v1.0.0
    형태로 버전 고정
  2. SSH 방식 선호: 프라이빗 리포 접근 시 SSH 키 사용
  3. 환경변수로 토큰 관리: PAT는 환경변수로 관리
  4. lockfile 커밋: package-lock.json 커밋으로 재현성 확보
  5. verbose 옵션 활용: 문제 발생 시 상세 로그 확인
  1. 使用特定版本/标签:以
    #v1.0.0
    形式固定版本
  2. 优先使用SSH方式:访问私有仓库时使用SSH密钥
  3. 用环境变量管理令牌:通过环境变量管理PAT
  4. 提交lockfile:提交package-lock.json确保可重现性
  5. 使用verbose选项:出现问题时查看详细日志

DON'T (금지)

禁止做法

  1. 토큰 하드코딩: package.json에 토큰 직접 입력 금지
  2. 최신 커밋 의존: 프로덕션에서
    #main
    대신 태그 사용
  3. sudo 남용: 권한 문제는 디렉토리 설정으로 해결
  4. 캐시 무시: 이상 동작 시 캐시 클리어 필수

  1. 硬编码令牌:禁止在package.json中直接输入令牌
  2. 依赖最新提交:生产环境中使用标签而非
    #main
  3. 滥用sudo:通过目录设置解决权限问题
  4. 忽略缓存:出现异常时必须清除缓存

Constraints

约束条件

필수 규칙 (MUST)

必须遵守的规则

  1. Git 설치 필수: npm git URL 설치 전 git 설치 확인
  2. 네트워크 접근: GitHub에 접근 가능한 환경 필요
  3. Node.js 버전: package.json의 engines 필드 확인
  1. 必须安装Git:使用npm Git URL安装前需确认已安装Git
  2. 网络访问:需要能访问GitHub的环境
  3. Node.js版本:确认符合package.json中engines字段的要求

금지 사항 (MUST NOT)

禁止事项

  1. 인증 토큰 노출: 로그, 코드에 토큰 노출 금지
  2. 무분별한 sudo: 권한 문제는 설정으로 해결
  3. 프로덕션에서 #main: 특정 버전/태그로 고정

  1. 暴露认证令牌:禁止在日志、代码中暴露令牌
  2. 滥用sudo:通过配置解决权限问题
  3. 生产环境使用#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