无法安装我发布到 GCP 中的 npm 注册表的范围包

Can't install a scoped package I published to a npm registry in GCP

我将几个 npm 包发布到托管在 GCP 中的私有 npm 注册表,我可以在注册表中看到所有版本。但是我无法下载软件包,因为安装命令会抛出 E404。

NPM 在尝试下载页面时抛出一般 404 错误:

npm ERR! code E404
npm ERR! 404 Not Found - GET https://europe-north1-npm.pkg.dev/[Project]/@[scope]/[packagename]/-/@[scope]/[packagename]-0.1.0.tgz
npm ERR! 404 
npm ERR! 404  '@[scope]/[packagename]@https://europe-north1-npm.pkg.dev/[Project]/@[scope]/[packagename]/-/@[scope]/[packagename]-0.1.0.tgz' 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.

打开正在解决 returns 这个错误的 url:

{"error":"Permission \"artifactregistry.repositories.downloadArtifacts\" denied on resource \"projects/[Project]/locations/europe-north1/repositories/@[scope]\" (or it may not exist)"}
{"error":"Unmatched scope name: \"\" != \"@[scope]\""}

另外,我查了一下,我的账号确实有downloadArtifacts的作用。 我不明白为什么它无法解析 URL 因为使用相同的配置我可以发布甚至 运行 npm view 包。 我已尝试创建全新的软件包、指定版本、重置身份验证令牌,但由于某种原因我仍然无法下载软件包。

如果有帮助,我当前的 .npmrc 文件如下所示:

registry:https://registry.npmjs.org/=true
@[scope]:registry=https://europe-north1-npm.pkg.dev/[project]/[repo name]/
//europe-north1-npm.pkg.dev/[project]/[repo name]/:_authToken=[gcp auth token]
//europe-north1-npm.pkg.dev/[project]/[repo name]/:always-auth=true
//registry.npmjs.org/:_authToken=[npm auth token]

原来这不是 GCP 特定问题,而是发布到 GCP 时的 Yarn Berry 问题。 正在生成的 tarballURL 使用截断的注册表 URL 这就是为什么我在尝试安装软件包时收到 404。 此处提出了对此的修复。 https://github.com/yarnpkg/berry/pull/3513