npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

ghnpm-cli

v1.0.2

Published

CLI tool to setup GitHub Packages authentication

Readme

ghnpm-cli

⚡ 一键配置 GitHub Packages NPM CLI,支持本地交互式和 CI/CD 自动化模式。

ghnpm-cli 是一个跨平台 Node.js CLI 工具,用于快速配置 GitHub Packages 的 npm 认证,包括:

  • macOS / Linux / Windows 支持
  • 自动检测已有 npm 登录
  • 用户级 / 全局 .npmrc 配置
  • Keychain / 系统凭证管理
  • 自动设置环境变量
  • 自动验证 npm 登录
  • 交互式菜单和非交互模式

安装

npm i -g ghnpm-cli

💡 脚本依赖 Node.js >= 16


功能特性

  1. 交互式配置 在本地终端运行时,提供交互式菜单,指导用户输入 GitHub Token、选择组织名、设置 npmrc 类型(用户级 / 全局)以及是否覆盖已有配置。

  2. 非交互参数模式 可通过命令行参数直接执行,无需交互,适合脚本或快速配置。

  3. CI/CD 自动化模式 提供 --token 即可自动覆盖 Keychain / npmrc / 环境变量,无需用户操作,适合自动化流水线。

  4. 自动检测已有登录 如果已登录 GitHub Packages,会提示是否覆盖现有 token,防止重复配置。

  5. 支持用户级 / 全局 npmrc 根据需要选择写入当前用户目录或全局路径。

  6. 环境变量管理 自动在 shell 配置文件(如 .zshrc.bashrc)或 Windows 系统变量中设置 NPM_TOKEN

  7. 登录验证 配置完成后自动验证 npm 登录是否成功,确保可用。


使用示例

1. 交互式模式(默认)

ghnpm setup

运行后会依次提示:

  • 输入 GitHub 组织名(默认 yolotechnology
  • 选择 npmrc 类型(用户级 / 全局)
  • 是否覆盖已有配置
  • 输入 GitHub Token(控制台隐藏输入)

2. 非交互参数模式

2.1 添加配置

ghnpm setup --token ghp_xxx --org openai --global --overwrite

参数说明:

| 参数 | 说明 | 示例 | | ----------------- | ---------------------------------- | ----------------- | | --token <token> | GitHub Token(必填) | --token ghp_xxx | | --org <orgName> | GitHub 组织名(可选,默认 yolotechnology) | --org openai | | --global | 是否写入全局 npmrc(默认用户级) | --global | | --overwrite | 是否覆盖已有 npmrc(默认询问或跳过) | --overwrite |

💡 提供 --token 即可进入 CI/CD 自动模式,无需交互。

2.2 清理配置

ghnpm clean

平台支持

  • macOS ✅
  • Linux ✅
  • Windows ✅

注意事项

  1. 安全性:GitHub Token 不会在控制台显示,脚本会安全写入系统 Keychain / 凭证管理。
  2. 环境变量:macOS / Linux 会写入 .zshrc / .bashrc.bash_profile;Windows 会写入系统变量(需重新打开终端生效)。
  3. CI/CD:在流水线中使用时,建议使用 --token + --global + --overwrite 自动化执行,无需用户干预。

依赖


License

MIT License © 2025