我正在尝试将大型 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>
Run Code Online (Sandbox Code Playgroud)
问题出在 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
Run Code Online (Sandbox Code Playgroud)
nexus.example.com:8081 - 是实际的nexus服务器主机和端口
authorization_token - 是nexus授权令牌
npmrepo - 是通过Nexus存储库管理器创建的npm存储库,其中ExamplePackage将发布
path_to_request_body_file - 应该是请求的文件路径body 文件,内容格式如下
{
"_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}"
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果包存档文件尚不存在,您可以使用npm pack它来生成它。
我曾经为包 archiveopenssl生成编码字符串,但也可以使用支持大文件的任何其他工具。
我已经使用 生成了包存档的 shasum ,也可以使用其他一些工具。base64openssl base64 -in ExamplePlugin-0.1.0.tgz -out ExamplePluginEncodedshasum -a 1 ExamplePlugin-0.1.0.tgz
我通过调试npm-registry-client获得了请求的格式和 JSON 负载,某些字段可能不是必需的,也可能有更多选项可用。
| 归档时间: |
|
| 查看次数: |
2598 次 |
| 最近记录: |