Already have your token? Run these 3 commands:
Windows users: see Step 1 below for PowerShell equivalent. For detailed instructions, read on.
Create .npmrc in your project root:
Set the NPM_TOKEN environment variable:
.npmrc to the project — it only references ${NPM_TOKEN}, not the actual secret.Add the token directly to ~/.npmrc (your home directory, never committed):
Authenticate interactively — this auto-updates ~/.npmrc:
@talespark/* packages come from the private registry. Everything else uses the public npm registry.
Should print your registry username.
Create this file in your home directory:
%USERPROFILE%\.upmconfig.toml~/.upmconfig.tomlEdit Packages/manifest.json in your Unity project:
In Unity: Window > Package Manager, then + > Add package by name.
Add NPM_TOKEN in repo Settings > Secrets, then:
Requires project-level .npmrc with ${NPM_TOKEN} (see Step 1).
@talespark/ for npm, com.talespark. for Unity.NPM_TOKEN env var is set and shell has been restarted.strict-ssl=false. Contact admin.Token validity: 365 days. Refresh anytime at Get Token.
已有 Token?执行以下 3 条命令即可:
Windows 用户请看下方步骤 1 的 PowerShell 命令。详细说明请继续阅读。
在项目根目录创建 .npmrc:
设置 NPM_TOKEN 环境变量:
.npmrc 可以提交到仓库,但 Token 本身不能。将 Token 直接写入 ~/.npmrc(主目录,不会被 git 追踪):
交互式登录,会自动更新 ~/.npmrc:
@talespark/* 从私有 registry 拉取,其他包仍从公共 npm 获取。
应输出你的 registry 用户名。
在用户主目录创建此文件:
%USERPROFILE%\.upmconfig.toml~/.upmconfig.toml编辑 Unity 项目的 Packages/manifest.json:
Unity 中:Window > Package Manager,点击 + > Add package by name。
在仓库 Settings > Secrets 添加 NPM_TOKEN:
需要项目级 .npmrc 使用 ${NPM_TOKEN} 变量(见步骤 1)。