首页 > 解决方案 > 无法使用 npm api 将 npm 包上传到 GitLab

问题描述

由于自托管 gitlab 服务器中的离线要求,尝试将 npm 包(本地计算机的依赖项)上传到 GitLab 包注册表。

https://docs.gitlab.com/ee/api/packages/npm.html#upload-a-package-file

curl -v -k --request PUT ^
    --data "@<full-path>/node_modules/array-unique/package.json" ^
    --data "versions=0.2.1" ^
        --header "Content-Type: application/json" ^
        --header "Authorization: Bearer <personal-access-token>" ^
    "https://gitlab.example.com/api/v4/projects/2/packages/npm/array-unique"

这就是回应

< HTTP/1.1 100 Continue
* We are completely uploaded and fine
< HTTP/1.1 400 Bad Request
< Server: nginx
< Date: Thu, 09 Sep 2021 12:35:55 GMT
< Content-Type: text/html; charset=utf-8
< Content-Length: 0
< Connection: keep-alive
< X-Request-Id: 01FF58XDK0NSJ77D6R9VJ8Z2RY
< X-Runtime: 0.003207

它似乎能够建立连接并发送文件数据,但它返回错误 400。这里有什么问题?

标签: npmgitlab

解决方案


推荐阅读