简体   繁体   English

NodeJS不稳定:无法npm安装需要编译的模块

[英]NodeJS unstable: unable to npm-install modules that need compilation

i've been working with NodeJS 0.11.x distros for some time now, mainly because i believe that generators and the yield statement bring big advances in terms of asynchronous manageability (see coffy-script and suspend ). 我已经使用NodeJS 0.11.x发行版已有一段时间了,主要是因为我相信生成器和yield语句在异步可管理性方面带来了很大的进步(请参阅coffy-scriptsuspend )。

that said, there's a serious setback when running bleeding-edge, unstable NodeJS installs: when doing npm install xy-module , gyp will fail (always? sometimes?) when trying to compile any C components. 就是说,运行尖端的,不稳定的NodeJS安装时会遇到严重的挫折:当执行npm install xy-module时,尝试编译任何C组件时gyp将会失败(总是?有时是?)。

is there a general reason this must be so? 有一定的普遍原因吗? is there any trick / patch / configuration i can apply to remedy the situation? 我可以采取任何技巧/补丁/配置来纠正这种情况吗? if a given module does compile on NodeJS 0.10.x, but fails on 0.11.x, should i expect it to compile on 0.12.x as soon as that becomes available? 如果给定的模块确实可以在NodeJS 0.10.x上编译,但是在0.11.x上失败,我是否希望它在可用时立即在0.12.x上编译?

Update i cross-posted the issue on the NodeJS mailing list, and ben noordhuis was kind enough to share some details . 更新我在NodeJS邮件列表上交叉发布了该问题, 本·诺德惠斯很友好,可以分享一些细节 quoting his message: 引用他的信息:

The two main changes are as follows: 两个主要更改如下:

  • Persistent<T> no longer derives from Handle<T> . Persistent<T>不再从Handle<T>派生。 To recreate the Handle from a Persistent, call Local<T>::New(isolate, persistent) . 要从持久性重新创建句柄,请调用Local<T>::New(isolate, persistent) You can obtain the isolate with Isolate::GetCurrent() (but note that Isolate::GetCurrent() will probably go away in newer versions of V8.) 您可以使用Isolate::GetCurrent()获得隔离(但请注意,在较新版本的V8中, Isolate::GetCurrent()可能会消失。)

  • The prototype of C++ callbacks and accessors has changed. C ++回调和访问器的原型已更改。 Before, your function looked like this: 以前,您的函数如下所示:

     Handle<Value> MyCallback(const Arguments& args) { HandleScope handle_scope; /* Do useful work, then: */ return handle_scope.Close(Integer::New(42)); /* Or: */ return handle_scope.Close(String::New("hello")); /* Or: */ return Null(); } 

    In v0.11 and v0.12 that becomes: 在v0.11和v0.12中变为:

     void MyCallback(const FunctionCallbackInfo<Value>& args) { Isolate* isolate = args.GetIsolate(); HandleScope handle_scope(isolate); /* Do useful work, then: */ args.GetReturnValue().Set(42); /* Or: */ args.GetReturnValue().Set(String::NewFromUtf8(isolate, "hello")); /* Or: */ args.GetReturnValue().SetNull(); } 

There have been more changes but these two impact every native add-on. 发生了更多更改,但是这两个都会影响每个本机加载项。

Answered in detail in NodeUp #52: http://nodeup.com/fiftytwo 在NodeUp#52中详细回答: http ://nodeup.com/fiftytwo

Summary: major changes in the v8 API, some minor changes in Node, and the changes are still ongoing. 简介:v8 API中的重大更改,Node中的一些较小更改,并且这些更改仍在进行中。 But there are two projects that are designed to help with the problem, NAN (github/rvagg/nan) and shim / node-addon-layer (github/tjfontaine/node-addon-layer). 但是有两个旨在解决该问题的项目,即NAN(github / rvagg / nan)和shim / node-addon-layer(github / tjfontaine / node-addon-layer)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM