【问题标题】:How can I build node.js without some internal modules?如何在没有一些内部模块的情况下构建 node.js?
【发布时间】:2017-08-22 14:09:30
【问题描述】:

我想构建一个特定的nodejs作为一个静态库,没有一些内部模块,如child_processdns等。

有没有一种可配置的方法来解决这个问题?

【问题讨论】:

    标签: node.js gyp chakracore


    【解决方案1】:

    node.gyp 中删除不需要的模块,从lib 文件夹中删除.js 文件,从lib/internal/module.js 中的builtinLibs 数组中删除它们,然后构建它。

    {
      'variables': {
        'v8_use_snapshot%': 'false',
        'v8_trace_maps%': 0,
        'node_use_dtrace%': 'false',
        'node_use_lttng%': 'false',
        'node_use_etw%': 'false',
        'node_use_perfctr%': 'false',
        'node_no_browser_globals%': 'false',
        'node_use_v8_platform%': 'true',
        'node_use_bundled_v8%': 'true',
        'node_shared%': 'false',
        'force_dynamic_crt%': 0,
        'node_module_version%': '',
        'node_shared_zlib%': 'false',
        'node_shared_http_parser%': 'false',
        'node_shared_cares%': 'false',
        'node_shared_libuv%': 'false',
        'node_use_openssl%': 'true',
        'node_shared_openssl%': 'false',
        'node_v8_options%': '',
        'node_enable_v8_vtunejit%': 'false',
        'node_core_target_name%': 'node',
        'library_files': [
          'lib/internal/bootstrap_node.js',
          'lib/async_hooks.js',
          'lib/assert.js',
          'lib/buffer.js',
          'lib/child_process.js', //Remove this line
          'lib/console.js',
          'lib/constants.js',
          'lib/crypto.js',
          'lib/cluster.js',
          'lib/dgram.js',
          'lib/dns.js', //Remove this line too
    [...]
    

    请注意,这些模块用于测试和基准测试,例如 child_proccesslib/internal/v8_prof_polyfill.jslib/internal/cluster/master.js

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-15
      • 1970-01-01
      • 1970-01-01
      • 2015-09-22
      • 2020-03-18
      • 1970-01-01
      相关资源
      最近更新 更多