我正在尝试将大型npm包发布到私有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的请求格式是什么,以便我可以尝试使用其他工具将包转换为编码的字符串?
发布于 2017-05-27 23:26:20
我已经使用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/ExamplePackagenexus.example.com:8081 -是实际的网络服务器主机和端口
authorization_token - is结点授权令牌
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有效负载,其中一些字段可能不是必需的,一些更多的选项也可能是可用的。
发布于 2020-04-29 03:50:22
npm publish -timeout=9999999这帮助我发布了150mb的包
https://stackoverflow.com/questions/43543459
复制相似问题