为什么我不能将 npm 模块发布到 Google Artifact Registry?

Why can I not publish npm module to Google Artifact Registry?

我运行

npx google-artifactregistry-auth --verbose

而且我似乎可以正常登录...

Retrieving application default credentials... Success!

所以现在我尝试部署并获取...

npm ERR! code ENEEDAUTH
npm ERR! need auth This command requires you to be logged in to https://us-central1-npm.pkg.dev/my-proj/npm-public/
npm ERR! need auth You need to authorize this machine using `npm adduser`

我已经在用于生成密钥文件的 IAM 服务帐户上设置了 roles/artifactregistry.writer 角色。

我错过了什么?

注册表信息必须在 $WORKING_DIR/.npmrc 而不是 ~/.npmrc

一旦我 运行 gcloud beta artifacts print-settings npm --repository=npm-public --location=us-central1 > .npmrc 然后 re-ran npx google-artifactregistry-auth 我就可以发布了。我尝试将 ~/.npmrc 用于 --repo-config,但它仍然无效