替换节点的本机域模块

Replace node's native domain module

有一个 native node module called domain 已弃用。我有兴趣复制它和 运行 有一些更改的本地版本。

我刚刚尝试从源代码复制模块并 require 副本,但出现此错误。

Assertion failed: (args[1]->IsObject()), function SetupDomainUse, file ../src/node.cc, line 950.
Abort trap: 6

这就是我 运行:

$ node -pe process.versions 
{ http_parser: '2.5.0',
  node: '2.5.0',
  v8: '4.2.77.21',
  uv: '1.6.1',
  zlib: '1.2.8',
  ares: '1.10.1-DEV',
  modules: '44',
  openssl: '1.0.2d' }

如何用我复制的本地模块替换节点的本机域模块?

您在 master 分支上使用 domain 模块,但您使用的是 io.js v2.5.0,因此您应该使用属于该版本的模块 (here ).

之后,您需要注释掉 this line 才能正常加载。