首页 > 解决方案 > GitLab-CE 13.7.4:NPM 发布 404 Not Found - PUT

问题描述

我正在尝试在自托管 GitLab 上发布私有 NPM 包。为此,我创建了一个 GitLab 项目,其中ID = 9包含 , 来托管我需要的所有 NPM 包。

package.json库是:

{
  "name": "@myscope/api-client",
  "version": "1.0.0",
  ...
  ...
  ...
  "publishConfig":{
    "@myscope:registry": "https://gitlab.mydomain.eu/api/v4/projects/9/packages/npm/"
  }
}

以下是.npmrc文件:

@myscope:registry=https://gitlab.mydomain.eu/api/v4/packages/npm/
//gitlab.mydomain.eu/api/v4/packages/npm/:_authToken=${GITLAB_AUTH_TOKEN}
//gitlab.mydomain.eu/api/v4/projects/9/packages/npm/:_authToken=${GITLAB_AUTH_TOKEN}

考虑到在线文档,我没有得到缺少的东西。但是,在运行npm publish命令时出现404 Not Found - PUT错误。提供的访问令牌具有所有权限,只是为了排除这种可能性。

$ GITLAB_AUTH_TOKEN=MyAccessToken npm publish dist
...
...
...
npm ERR! code E404
npm ERR! 404 Not Found - PUT https://gitlab.mydomain.eu/api/v4/packages/npm/@myscope%2fapi-client
npm ERR! 404 
npm ERR! 404  '@myscope/api-client@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!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

更新根据https://docs.gitlab.com/ee/user/packages/npm_registry/index.html#authenticate-with-a-ci-job-token.npmrc上的文档, 我也尝试过以下操作但没有成功。

@myscope:registry=https://gitlab.mydomain.eu/api/v4/projects/9/packages/npm/
//gitlab.mydomain.eu/api/v4/projects/9/packages/npm/:_authToken=${GITLAB_AUTH_TOKEN}

标签: npmgitlabnpm-publish

解决方案


推荐阅读