npm-git-install by akillness/oh-my-skills
npx skills add https://github.com/akillness/oh-my-skills --skill npm-git-install介绍如何直接从 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://git@github.com:JEO-tech-ai/supercode.git#main
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
npm install -g git+https://github.com/JEO-tech-ai/supercode.git#main --verbose
npm 从 Git URL 安装时执行的操作:
1. Git 克隆
└─ 克隆指定分支(#main)的仓库
↓
2. 安装依赖
└─ 安装 package.json 中的依赖项
↓
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://git@github.com: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 "your_email@example.com"
# 2. 在 GitHub 注册公钥
cat ~/.ssh/id_ed25519.pub
# GitHub → 设置 → SSH 密钥 → 新建 SSH 密钥
# 3. 通过 SSH 方法安装
npm install git+ssh://git@github.com:owner/private-repo.git
# 1. 在 GitHub 创建 PAT
# GitHub → 设置 → 开发者设置 → 个人访问令牌
# 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 git@github.com
# 缓存凭据
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": "生成文档",
"icon": "docs",
"prompt": "生成全面的文档"
}
],
"architectureMode": {
"enabled": true,
"detailLevel": "detailed"
}
}
#v1.0.0 格式固定版本#main#npm #git #github #install #package-management #node
每周安装次数
1
仓库
GitHub 星标数
3
首次出现
1 天前
安全审计
已安装于
mcpjam1
claude-code1
junie1
windsurf1
zencoder1
crush1
Covers how to install npm packages directly from GitHub repositories. Useful for installing packages not in the npm registry, specific branches, or private repositories.
npm install git+https://github.com/<owner>/<repo>.git#<branch|tag|commit>
# Specific branch
npm install -g git+https://github.com/JEO-tech-ai/supercode.git#main
# Specific tag
npm install git+https://github.com/owner/repo.git#v1.0.0
# Specific commit
npm install git+https://github.com/owner/repo.git#abc1234
# Default branch (omit #)
npm install git+https://github.com/owner/repo.git
npm install -g git+ssh://git@github.com:JEO-tech-ai/supercode.git#main
npm install -g git+https://github.com/JEO-tech-ai/supercode.git#main --verbose
What npm performs when installing from a Git URL:
1. Git Clone
└─ Clone repository at specified branch (#main)
↓
2. Install Dependencies
└─ Install dependencies in package.json
↓
3. Run Prepare Script
└─ Run "prepare" script (TypeScript compile, build, etc.)
↓
4. Register Global Binary
└─ Link executable from bin field to global path
# What npm does internally
git clone https://github.com/owner/repo.git /tmp/npm-xxx
cd /tmp/npm-xxx
git checkout main
npm install
npm run prepare # Run if exists
cp -r . /usr/local/lib/node_modules/repo/
ln -s ../lib/node_modules/repo/bin/cli.js /usr/local/bin/repo
# Check global npm path
npm root -g
# macOS/Linux: /usr/local/lib/node_modules
# Windows: C:\Users\<username>\AppData\Roaming\npm\node_modules
# Check installed package
npm list -g <package-name>
# Check binary location
which <command>
# or
npm bin -g
| Platform | Package Location | Binary Location |
|---|---|---|
| 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://git@github.com: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. Generate SSH key
ssh-keygen -t ed25519 -C "your_email@example.com"
# 2. Register public key on GitHub
cat ~/.ssh/id_ed25519.pub
# GitHub → Settings → SSH Keys → New SSH Key
# 3. Install via SSH method
npm install git+ssh://git@github.com:owner/private-repo.git
# 1. Create PAT on GitHub
# GitHub → Settings → Developer settings → Personal access tokens
# 2. Install with token in URL
npm install git+https://<token>@github.com/owner/private-repo.git
# 3. Use environment variable (recommended for security)
export GITHUB_TOKEN=ghp_xxxxxxxxxxxx
npm install git+https://${GITHUB_TOKEN}@github.com/owner/private-repo.git
# ~/.npmrc
//github.com/:_authToken=${GITHUB_TOKEN}
# Method 1: Change ownership
sudo chown -R $(whoami) /usr/local/lib/node_modules
# Method 2: Change npm directory (recommended)
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
# Test SSH connection
ssh -T git@github.com
# Cache credentials
git config --global credential.helper store
# or macOS
git config --global credential.helper osxkeychain
# For TypeScript projects
npm install -g typescript
# Verbose log on build failure
npm install git+https://... --verbose 2>&1 | tee npm-install.log
# Clear npm cache
npm cache clean --force
# Reinstall
npm uninstall -g <package>
npm install -g git+https://...
# Update to latest version (reinstall)
npm uninstall -g <package>
npm install -g git+https://github.com/owner/repo.git#main
# Update package.json dependency
npm update <package>
# Check installed version
npm list -g <package>
# Check remote latest commit
git ls-remote https://github.com/owner/repo.git HEAD
npm uninstall -g <package>
# Global install
npm install -g git+https://github.com/JEO-tech-ai/supercode.git#main
# Verify installation
supercode --version
// .supercoderc or 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 format#main in production#npm #git #github #install #package-management #node
Weekly Installs
1
Repository
GitHub Stars
3
First Seen
1 day ago
Security Audits
Gen Agent Trust HubFailSocketPassSnykFail
Installed on
mcpjam1
claude-code1
junie1
windsurf1
zencoder1
crush1
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
115,300 周安装
Refero Design:研究优先设计方法,学习最佳实践,打造独特用户体验
1,000 周安装
Flutter MVVM架构实现指南:可扩展应用开发与provider依赖注入
1,100 周安装
CTF杂项挑战快速参考指南 | 沙箱逃逸、编码解码、信号处理与提权技术
1,200 周安装
安全最佳实践指南:识别语言框架漏洞,编写安全代码与生成修复报告
1,100 周安装
Playwright 交互式测试技能:持久会话调试本地Web/Electron应用,无需重启工具链
1,100 周安装
Confluence API 集成指南:使用 Membrane CLI 实现团队协作与文档管理自动化
1,100 周安装