【发布时间】:2021-06-30 14:34:00
【问题描述】:
我的免费 github 组织中有一个私人仓库。当我尝试将私有包发布到带有操作的 Github 包时,我收到以下错误:
npm ERR! 401 Unauthorized - PUT https://npm.pkg.github.com/@organization%2ftailwind - Your request could not be authenticated by the GitHub Packages service. Please ensure your access token is valid and has the appropriate scopes configured.
我的 github 操作 main.yml 文件如下所示:
name: Node.js Package
on:
push:
branches:
- main
jobs:
publish-gpr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://npm.pkg.github.com/
scope: '@organization'
- run: npm install
- run: npm publish
env:
NODE_AUTH_TOKEN: $({secrets.GITHUB_TOKEN})
而我的package.json 看起来像这样:
{
"name": "@organization/tailwind",
"version": "1.0.0",
"description": "My Package Description",
"main": "index.js",
"publishConfig": {
"registry": "https://npm.pkg.github.com/@organization"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/organization/tailwind.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/organization/tailwind/issues"
},
"homepage": "https://github.com/organization/tailwind#readme"
}
我需要进行哪些更改才能使其正常工作?我还尝试从我的 github 帐户使用具有读/写包权限的个人访问令牌,但这也不起作用。
【问题讨论】:
-
我会说令牌没有足够的权限来执行错误消息所说的任务。您可以自己创建一个新令牌并设置必要的权限。该过程在documentation 中进行了描述。
-
@flaxel 它不起作用。我创建了一个具有读、写包权限的新个人访问令牌,但我得到了同样的错误......
-
@Niklas - 您是否设法解决了您的问题?如果是,您是如何解决的。 TIA。
标签: github github-actions github-package-registry