发布大型NPM软件包

我试图发布一个私人的Nexus 3 nmp存储库大npm包,但操作失败,出现以下错误

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级别,并在构build向Nexus发布请求时出现。

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

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

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

我用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授权令牌
npmrepo – 是一个通过Nexus Repository Manager创build的npm存储库,其中的ExamplePackage将被发布
path_to_request_body_file – 应该是具有内容格式的请求主体文件的文件path,如下所示

 { "_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为包档案生成base64编码的stringopenssl base64 -in ExamplePlugin-0.1.0.tgz -out ExamplePluginEncoded ,但是可以使用任何其他支持大文件的工具。
我已经使用shasum -a 1 ExamplePlugin-0.1.0.tgz生成了包归档shasum -a 1 ExamplePlugin-0.1.0.tgz ,也可以使用其他一些工具。

我得到了请求的格式和debuggingnpm-registry-client的JSON有效载荷,有些字段可能不是必需的,还有一些选项可用。