为什么 npm publish 告诉我包不存在?

Why is npm publish telling me the package doesn't exist?

我第一次尝试将 npm 包上传到 GitLab 注册表。我根据 documentation 设置范围和 npm 配置条目,但是当我执行 npm publish 时,出现以下错误:

npm notice Publishing to https://git.myorg.com/api/v4/projects/123/packages/npm/
npm ERR! code E404
npm ERR! 404 Not Found - PUT https://git.myorg.com/api/v4/projects/123/packages/npm/@myscope%2fmyproject
npm ERR! 404
npm ERR! 404  '@myscope/myproject@1.0.0' is not in this 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.

所以我尝试发布它,但错误提示它不存在,我应该发布它...什么?!

从最后两行来看,错误似乎是安装失败,但我确实使用了 npm publish。此外,在 PUT 命令中,范围和项目名称之间的最后一个斜杠被替换为 %2f。不知道为什么会发生这种情况,也不知道为什么它没有发生在其他地方,但这也许是潜在问题的征兆?

好吧,这是我自己的错。在执行 npm config set @foo:registry https://gitlab.example.com/api/v4/projects/<your_project_id>/packages/npm/ 时,我在 <your_project_id> 的位置输入了组 ID 而不是项目 ID。我们仅将组用于包注册表项目,所以我让他们感到困惑。