Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Github 从GH软件包安装NPM:在本地工作,但不在GH操作中_Github_Github Actions - Fatal编程技术网

Github 从GH软件包安装NPM:在本地工作,但不在GH操作中

Github 从GH软件包安装NPM:在本地工作,但不在GH操作中,github,github-actions,Github,Github Actions,我已经将一个私有包发布到我们组织的包存储库中 - name: 'authenticate with GH package registry' run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc 根据文档,我在另一个项目的根目录中添加了一个.npmrc文件,内容如下: registry=https://npm.pkg.github.com/my-org 在我的本地~/

我已经将一个私有包发布到我们组织的包存储库中

  - name: 'authenticate with GH package registry'
    run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
根据文档,我在另一个项目的根目录中添加了一个.npmrc文件,内容如下:

registry=https://npm.pkg.github.com/my-org
在我的本地~/.npmrc中,位于npm.pkg.github.com的我的Authtoken

我在my package.json中安装了发布的包,在package.json中有以下条目

"@my-org/my-package": "^1.0.0",
在本地安装时,这可以正常工作

通过Github操作安装时,安装失败,出现以下错误:

npm ERR! code E404
npm ERR! 404 Not Found - GET https://npm.pkg.github.com/my-org/@my-org%2fmy-package - npm package "my-package" does not exist under owner "my-org"
npm ERR! 404 
npm ERR! 404  '@my-org/my-package@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!)
似乎“我的组织”在包的路径中被使用了两次? 为什么它在本地工作,但在Github操作中不工作

最初,my.npmrc只是这样(没有向注册表URL添加组织):

这在当地也很管用

它也适用于github操作中的所有作用域包(如@coogle cloud),但不适用于非作用域包:

npm ERR! code E404
npm ERR! 404 Not Found - GET https://npm.pkg.github.com/chai
npm ERR! 404 
npm ERR! 404  'chai@4.2.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.
更新: 因此,我使用我的个人accesstoken(在本地工作)并提交,现在安装工作流成功了

文档()说:“GITHUB_令牌具有read:packages和write:packages作用域。” 这还不够吗


我的个人访问令牌有delete:packages、read:packages、repo、write:packages。

隐藏在任意twitter线程中的信息是GITHUB\u令牌只能访问当前的repo。

解决方案是显式定义一个个人(sic!)访问令牌,并使用此密钥将其放入存储库的机密存储库中,以对包存储库进行身份验证

  - name: 'authenticate with GH package registry'
    run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc