gpt4 book ai didi

node.js - 发布大型 NPM 包

转载 作者:行者123 更新时间:2023-12-03 05:25:09 28 4
gpt4 key购买 nike

我正在尝试将大型 npm 包发布到私有(private) Nexus 3 nmp 存储库,但操作失败并出现以下错误

npm ERR! node v7.7.4
npm ERR! npm v4.1.2

npm ERR! "toString()" failed
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>

问题出现在 V8 级别,并在构建发布到 Nexus 的请求时出现。

发布大型 npm 包不是一个好习惯,但它是第三方插件,我们的项目需要它。

有没有办法配置/修补 V8 以支持更大的文件大小?

将 npm 包上传到 nexus 的请求格式是什么,以便我可以尝试使用其他工具将包转换为编码字符串?

最佳答案

我已经使用 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 - 是实际的 Nexus 服务器主机和端口
authorization_token - 是 Nexus 授权 token
npmrepo - 是通过 Nexus Repository Manager 创建的 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": "example.user@test.com"
}
],
"_id": "ExamplePlugin@0.1.0",
"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": "example.user@test.com"
}
],
"_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}"
}
}
}

如果包存档文件尚不存在,您可以使用 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 负载,某些字段可能不是必需的,也可能有更多选项可用。

关于node.js - 发布大型 NPM 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43543459/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com