Gitlab软件包注册表在npm发布时出现404错误

3
我正在尝试将一个软件包发布到Gitlab软件包注册表,但它一直报错说404 @my-scope/<package-name> is not in this registry

最初我按照官方文档的说明进行操作。
这是我的.npmrc文件内容:
@my-scope:registry=https://gitlab.com/api/v4/projects/<project_id>/packages/npm/
//gitlab.com/api/v4/projects/<project_id>/packages/npm/:_authToken=${TOKEN}

同时,我已将publishConfig添加到package.json中。

  "publishConfig": {
    "@my-scope:registry": "https://gitlab.com/api/v4/projects/<project_id>/packages/npm/"
  },

当我运行npm publish时,我一直收到以下的404错误。
npm notice Publishing to https://gitlab.com/api/v4/projects/<project_id>/packages/npm/
npm ERR! code E404
npm ERR! 404 Not Found - PUT https://gitlab.com/api/v4/projects/<project_id>/packages/npm/@my-scope%2fpackage-name
npm ERR! 404 
npm ERR! 404  '@my-scope/package-name@1.5.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
1个回答

0

根据文档,您的.npmrc应该如下所示:

@foo:registry=https://gitlab.example.com/api/v4/packages/npm/
//gitlab.example.com/api/v4/packages/npm/:_authToken=${MY_TOKEN}
//gitlab.example.com/api/v4/projects/<your_project_id>/packages/npm/:_authToken=${MY_TOKEN}


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接