我用CURL發佈了這個包。請求的格式是
curl -H "Content-Type: application/json"\
-H "Authorization: Basic ${authorization_token}"\
-H "Content-Length: ${actual size of the request body in bytes (just check the size of the request body file)}"\
-H "Accept-Encoding: gzip"\
-H "version: 8.1.1"\
-H "Accept: application/json"\
-H "npm-session: a972cb330cbacab5"\
-H "npm-in-ci: false"\
-H "User-Agent: node/v7.7.4"\
-H "Host: nexus.example.com:8081"\
-X PUT\
--data-binary @path_to_request_body_file\
--verbose\
http://nexus.example.com:8081/nexus/repository/npmrepo/ExamplePackage
nexus.example.com:8081 - 是實際的關係服務器主機和端口
authorization_token - 是關係授權令牌
npmrepo - 通過的Nexus庫創建的NPM庫經理,其中ExamplePackage將發佈
path_to_request_body_file - 應該是文件路徑與內容的格式請求體文件如下
{
"_id": "ExamplePlugin",
"name": "ExamplePlugin",
"description": "Example Plugin",
"dist-tags": {
"latest": "0.1.0"
},
"versions": {
"0.1.0": {
"name": "ExamplePlugin",
"version": "0.1.0",
"cordova_name": "ExamplePlugin",
"description": "Example Plugin",
"license": "Apache 2.0",
"keywords": [
"ExamplePlugin",
"StackoverflowExample"
],
"platforms": [
"ios",
"android"
],
"engines": [],
"dependencies": {},
"maintainers": [
{
"name": "example_nexus_user",
"email": "[email protected]"
}
],
"_id": "[email protected]",
"dist": {
"shasum": "${shasum of the package archive file}",
"tarball": "http://nexus.example.com:8081/nexus/repository/npmrepo/ExamplePlugin/-/ExamplePlugin-0.1.0.tgz"
}
}
},
"readme": "",
"access": "public",
"maintainers": [
{
"name": "example_nexus_user",
"email": "[email protected]"
}
],
"_attachments": {
"ExamplePlugin-0.1.0.tgz": {
"content_type": "application/octet-stream",
"data": "${Base64 encoded content of the npm package archive}",
"length": "${actual size of the package archive in bytes}"
}
}
}
如果包檔案文件d不存在,您可以使用npm pack
來生成它。
我已使用openssl
爲包檔案openssl base64 -in ExamplePlugin-0.1.0.tgz -out ExamplePluginEncoded
生成base64
編碼字符串,但可以使用任何其他支持大文件的工具。
我已經使用shasum -a 1 ExamplePlugin-0.1.0.tgz
生成了包歸檔的shasum,也可以使用其他一些工具。
我得到了請求的格式和調試npm-registry-client的JSON有效載荷,其中一些字段可能不是必需的,也可能有更多的選項可用。
「大」有多大?我們在談論什麼文件大小?你能詳細瞭解爲什麼「toString()」失敗嗎?你確定這是你遇到的尺寸限制嗎? – jmrk
是的,它很大。它差不多是1GB。有關於這個問題的一些帖子,這裏是其中之一https://github.com/npm/npm/issues/9552。但我找不到解決方案。 – Nenad