问题描述
我正在尝试为NPM项目设置Github软件包,但是遇到了一些问题。
我在某个特定的组织下有一个仓库:
my-orgname/my-repo-name
这个仓库是私人的
my-orgname/my-repo-name
存储库中的代码包含一个NPM模块。
项目中的package.json
{
"name": "@my-orgname/my-repo-name","version": "1.0.0","description": ".....","publishConfig": {
"registry": "https://npm.pkg.github.com/"
},"repository": {
"type": "git","url": "https://github.com/my-orgname/my-repo-name"
},.....
.npmrc在项目文件夹中
registry=https://npm.pkg.github.com/my-orgname
〜/ .npmrc文件
//registry.npmjs.org/:_authToken=<TOKEN>
//npm.pkg.github.com/:_authToken=<TOKEN>
在项目文件夹中。
npm publish
结果
npm ERR! 404 Not Found - PUT https://npm.pkg.github.com/@my-orgname%2fmy-repo-name - The expected resource was not found.
npm ERR! 404
npm ERR! 404 '@my-orgname/my-repo-name@1.0.0' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball,folder,http url,or git url.
解决方法
我遇到了类似的问题,发现我需要给我的 github 个人访问令牌以下权限:
- repo(完全控制私有仓库)
- write:packages(将包上传到 github 包注册表)
- read:packages(从 github 包注册表下载包)