nodejs 从0.12 升级到5.或者4 版本,一些库无法安装问题
本来用的0.12.7 版本,现在发现官方已经升级到了4.2.4 和 5.3.0 , 升级到4.或者 5的版本之后,发现原来使用的一些库无法安装,主要是ccap和ursa,主要记录如下: 1、
../node_modules/nan/nan.h:1939: error: ‘NewInstance’ was not declared in this scope
../node_modules/nan/nan.h: In function ‘void
../node_modules/nan/nan.h:2162: error: ‘GetFunction’ was not declared in this scope
/usr/local/node-v4.2.4-linux-x64/lib/node_modules/ursa/.node-gyp/4.2.4/include/node/v8.h:3021: error: argument dependent lookup finds ‘class v8::Set’
../node_modules/nan/nan.h:2162: error: in call to ‘Set’
../node_modules/nan/nan.h: In constructor ‘Nan::Tap::Tap(v8::Local<v8::Value>)’:
../node_modules/nan/nan.h:2169: error: no matching function for call to ‘To(v8::Local<v8::Value>&)’
../node_modules/nan/nan.h:2212: error: ISO C++ forbids declaration of ‘MaybeLocal’ with no type
../node_modules/nan/nan.h:2212: error: expected ‘;’ before ‘<’ token
../src/ursaNative.cc:344: error: ‘class v8::Local<v8::Boolean>’ has no member named ‘ToLocalChecked’
gyp ERR! build error
2、
/usr/local/node-v4.2.4-linux-x64/lib/node_modules/ccap/.node-gyp/4.2.4/include/node/v8.h:3205: error: ‘nullptr’ was not declared in this scope
/usr/local/node-v4.2.4-linux-x64/lib/node_modules/ccap/.node-gyp/4.2.4/include/node/v8.h: In member function ‘v8::Local<T> v8::MaybeLocal<T>::ToLocalChecked()’:
/usr/local/node-v4.2.4-linux-x64/lib/node_modules/ccap/.node-gyp/4.2.4/include/node/v8.h:7164: error: ‘nullptr’ was not declared in this scope
make: *** [Release/obj.target/hcaptha/addon/hcaptha.o] Error 1
make: Leaving directory `/usr/local/node-v4.2.4-linux-x64/lib/node_modules/ccap/build'
gyp ERR! build error
4 回复
node 4.0 的时候,v8 接口改了不少。升级一下那些库就好了。
下载了源代码,编译,没想到,make 没有通过。。。
g++ -pthread -rdynamic -m64 -fuse-ld=gold -B/usr/src/node-v4.2.4/third_party/binutils/Linux_x64/Release/bin -m64 -o /usr/src/node-v4.2.4/out/Release/mksnapshot -Wl,--start-group /usr/src/node-v4.2.4/out/Release/obj.target/mksnapshot/deps/v8/src/snapshot/mksnapshot.o /usr/src/node-v4.2.4/out/Release/obj.target/deps/v8/tools/gyp/libv8_base.a /usr/src/node-v4.2.4/out/Release/obj.target/deps/v8/tools/gyp/libv8_nosnapshot.a /usr/src/node-v4.2.4/out/Release/obj.target/deps/v8/tools/gyp/libv8_libplatform.a /usr/src/node-v4.2.4/out/Release/obj.target/deps/v8/tools/gyp/libv8_libbase.a -Wl,--end-group -ldl -lrt
collect2: fatal error: cannot find 'ld'
compilation terminated.
make[1]: *** [/usr/src/node-v4.2.4/out/Release/mksnapshot] Error 1
make[1]: Leaving directory `/usr/src/node-v4.2.4/out'
make: *** [node] Error 2
你这个这个问题我可以回答 你帖子里面的问题很简单,需要升级GCC至少到4.8,让它可以编译C++11 第二个问题是因为找不到 ld.gold 说明你的 binutils 版本不够(下载 GNU binutils 使用 --enable-gold 来编译)或者没安装 binutils-gold 包(yum、apt-get 来安装)。
collect2: fatal error: cannot find 'ld'
的问题具体可以参考:https://github.com/nodejs/node/issues/4212 正如楼上所说的。
另外一个简单的解决方案是./configure --without-snapshot