首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >发布大型NPM包

发布大型NPM包
EN

Stack Overflow用户
提问于 2017-04-21 21:03:14
回答 2查看 2.9K关注 0票数 5

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

代码语言:javascript
运行
复制
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的请求格式是什么,以便我可以尝试使用其他工具将包转换为编码的字符串?

EN

回答 2

Stack Overflow用户

发布于 2017-05-27 23:26:20

我已经使用CURL发布了这个包。请求的格式为

代码语言:javascript
运行
复制
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 - is结点授权令牌

npmrepo -是通过Nexus repository Manager创建的npm存储库,将在其中发布ExamplePackage

path_to_request_body_file -应为请求体文件的文件路径,内容格式如下

代码语言:javascript
运行
复制
{
  "_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有效负载,其中一些字段可能不是必需的,一些更多的选项也可能是可用的。

票数 3
EN

Stack Overflow用户

发布于 2020-04-29 03:50:22

npm publish -timeout=9999999这帮助我发布了150mb的包

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43543459

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档