node 4.4.5 在centos 上的安装
一、当前 系统 版本
[root@master src]# lsb_release -a LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch Distributor ID: CentOS Description: CentOS release 6.8 (Final) Release: 6.8 Codename: Final [root@master src]#
二、当前node版本
[root@master src]# node -v v0.12.6
三、参考安装步骤http://www.runoob.com/nodejs/nodejs-install-setup.html
到make时报错
[root@master node-v4.4.5]# make make -C out BUILDTYPE=Release V=1 make[1]: Entering directory `/usr/local/src/node-v4.4.5/out' g++ '-DV8_TARGET_ARCH_X64' '-DENABLE_DISASSEMBLER' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_STATIC' -I../deps/v8 -pthread -Wall -Wextra -Wno-unused-parameter -m64 -B/usr/local/src/node-v4.4.5/third_party/binutils/Linux_x64/Release/bin -fno-strict-aliasing -m64 -O3 -ffunction-sections -fdata-sections -fno-omit-frame-pointer -fdata-sections -ffunction-sections -O3 -fno-rtti -fno-exceptions -std=gnu++0x -MMD -MF /usr/local/src/node-v4.4.5/out/Release/.deps//usr/local/src/node-v4.4.5/out/Release/obj.target/v8_base/deps/v8/src/accessors.o.d.raw -c -o /usr/local/src/node-v4.4.5/out/Release/obj.target/v8_base/deps/v8/src/accessors.o ../deps/v8/src/accessors.cc In file included from ../deps/v8/src/v8.h:29, from ../deps/v8/src/accessors.cc:5: ../deps/v8/include/v8.h: In constructor ‘v8::MaybeLocal<T>::MaybeLocal()’: ../deps/v8/include/v8.h:353: error: ‘nullptr’ was not declared in this scope ../deps/v8/include/v8.h: In member function ‘bool v8::MaybeLocal<T>::IsEmpty() const’: ../deps/v8/include/v8.h:360: error: ‘nullptr’ was not declared in this scope ../deps/v8/include/v8.h: In member function ‘bool v8::MaybeLocal<T>::ToLocal(v8::Local<S>*) const’: ../deps/v8/include/v8.h:364: error: ‘nullptr’ was not declared in this scope ../deps/v8/include/v8.h: In member function ‘bool v8::WeakCallbackInfo<T>::IsFirstPass() const’: ../deps/v8/include/v8.h:430: error: ‘nullptr’ was not declared in this scope ../deps/v8/include/v8.h: At global scope: ../deps/v8/include/v8.h:469: error: expected unqualified-id before ‘using’ ../deps/v8/include/v8.h: In constructor ‘v8::Global<T>::Global()’: ../deps/v8/include/v8.h:790: error: ‘nullptr’ was not declared in this scope ../deps/v8/include/v8.h: In constructor ‘v8::Global<T>::Global(v8::Global<T>&&)’: ../deps/v8/include/v8.h:815: error: ‘nullptr’ was not declared in this scope ../deps/v8/include/v8.h: In member function ‘v8::Global<T>& v8::Global<T>::operator=(v8::Global<S>&&)’: ../deps/v8/include/v8.h:827: error: ‘nullptr’ was not declared in this scope ../deps/v8/include/v8.h: At global scope: ../deps/v8/include/v8.h:852: error: expected unqualified-id before ‘using’ ../deps/v8/include/v8.h:1089: error: ‘nullptr’ was not declared in this scope ../deps/v8/include/v8.h:1095: error: ‘nullptr’ was not declared in this scope ../deps/v8/include/v8.h: In member function ‘v8::MaybeLocal<v8::Object> v8::Function::NewInstance(v8::Local<v8::Context>) const’: ../deps/v8/include/v8.h:3205: error: ‘nullptr’ was not declared in this scope ../deps/v8/include/v8.h: In member function ‘v8::Local<T> v8::MaybeLocal<T>::ToLocalChecked()’: ../deps/v8/include/v8.h:7164: error: ‘nullptr’ was not declared in this scope In file included from ../deps/v8/src/checks.h:9, from ../deps/v8/src/v8.h:31, from ../deps/v8/src/accessors.cc:5: ../deps/v8/src/base/logging.h: In function ‘std::string* v8::base::CheckEQImpl(const Lhs&, const Rhs&, const char*)’: ../deps/v8/src/base/logging.h:123: error: ‘nullptr’ was not declared in this scope ../deps/v8/src/base/logging.h: In function ‘std::string* v8::base::CheckEQImpl(int, int, const char*)’: ../deps/v8/src/base/logging.h:123: error: ‘nullptr’ was not declared in this scope ../deps/v8/src/base/logging.h: In function ‘std::string* v8::base::CheckNEImpl(const Lhs&, const Rhs&, const char*)’: ../deps/v8/src/base/logging.h:124: error: ‘nullptr’ was not declared in this scope ../deps/v8/src/base/logging.h: In function ‘std::string* v8::base::CheckNEImpl(int, int, const char*)’: ../deps/v8/src/base/logging.h:124: error: ‘nullptr’ was not declared in this scope ../deps/v8/src/base/logging.h: In function ‘std::string* v8::base::CheckLEImpl(const Lhs&, const Rhs&, const char*)’: ../deps/v8/src/base/logging.h:125: error: ‘nullptr’ was not declared in this scope ../deps/v8/src/base/logging.h: In function ‘std::string* v8::base::CheckLEImpl(int, int, const char*)’: ../deps/v8/src/base/logging.h:125: error: ‘nullptr’ was not declared in this scope ../deps/v8/src/base/logging.h: In function ‘std::string* v8::base::CheckLTImpl(const Lhs&, const Rhs&, const char*)’: ../deps/v8/src/base/logging.h:126: error: ‘nullptr’ was not declared in this scope ../deps/v8/src/base/logging.h: In function ‘std::string* v8::base::CheckLTImpl(int, int, const char*)’: ../deps/v8/src/base/logging.h:126: error: ‘nullptr’ was not declared in this scope ../deps/v8/src/base/logging.h: In function ‘std::string* v8::base::CheckGEImpl(const Lhs&, const Rhs&, const char*)’: ../deps/v8/src/base/logging.h:127: error: ‘nullptr’ was not declared in this scope ../deps/v8/src/base/logging.h: In function ‘std::string* v8::base::CheckGEImpl(int, int, const char*)’: ../deps/v8/src/base/logging.h:127: error: ‘nullptr’ was not declared in this scope ../deps/v8/src/base/logging.h: In function ‘std::string* v8::base::CheckGTImpl(const Lhs&, const Rhs&, const char*)’: ../deps/v8/src/base/logging.h:128: error: ‘nullptr’ was not declared in this scope ../deps/v8/src/base/logging.h: In function ‘std::string* v8::base::CheckGTImpl(int, int, const char*)’: ../deps/v8/src/base/logging.h:128: error: ‘nullptr’ was not declared in this scope In file included from ../deps/v8/src/base/platform/platform.h:29, from ../deps/v8/src/utils.h:18, from ../deps/v8/src/v8.h:34, from ../deps/v8/src/accessors.cc:5: ../deps/v8/src/base/platform/mutex.h: At global scope: ../deps/v8/src/base/platform/mutex.h:36: error: variable ‘v8::base::Mutex v8::base::final’ has initializer but incomplete type ../deps/v8/src/base/platform/mutex.h:37: error: expected primary-expression before ‘public’ ../deps/v8/src/base/platform/mutex.h:37: error: expected ‘}’ before ‘public’ ../deps/v8/src/base/platform/mutex.h:37: error: expected ‘,’ or ‘;’ before ‘public’ ../deps/v8/src/base/platform/mutex.h:39: error: expected constructor, destructor, or type conversion before ‘;’ token ../deps/v8/src/base/platform/mutex.h: In function ‘v8::base::NativeHandle& v8::base::native_handle()’: ../deps/v8/src/base/platform/mutex.h:63: error: ‘native_handle_’ was not declared in this scope ../deps/v8/src/base/platform/mutex.h: At global scope: ../deps/v8/src/base/platform/mutex.h:65: error: non-member function ‘const v8::base::NativeHandle& v8::base::native_handle()’ cannot have cv-qualifier ../deps/v8/src/base/platform/mutex.h: In function ‘const v8::base::NativeHandle& v8::base::native_handle()’: ../deps/v8/src/base/platform/mutex.h:65: error: new declaration ‘const v8::base::NativeHandle& v8::base::native_handle()’ ../deps/v8/src/base/platform/mutex.h:62: error: ambiguates old declaration ‘v8::base::NativeHandle& v8::base::native_handle()’ ../deps/v8/src/base/platform/mutex.h:66: error: ‘native_handle_’ was not declared in this scope ../deps/v8/src/base/platform/mutex.h: At global scope: ../deps/v8/src/base/platform/mutex.h:69: error: expected unqualified-id before ‘private’ ../deps/v8/src/base/platform/mutex.h:89: error: ‘friend’ used outside of class ../deps/v8/src/base/platform/mutex.h:91: error: expected unqualified-id before ‘const’ ../deps/v8/src/base/platform/mutex.h:91: error: expected ‘)’ before ‘const’ ../deps/v8/src/base/platform/mutex.h:91: error: ‘void v8::base::operator=(const v8::base::Mutex&)’ must be a nonstatic member function ../deps/v8/src/base/platform/mutex.h:104: error: expected initializer before ‘<’ token ../deps/v8/src/base/platform/mutex.h:130: error: variable ‘v8::RecursiveMutex v8::final’ has initializer but incomplete type ../deps/v8/src/base/platform/mutex.h:131: error: expected primary-expression before ‘public’ ../deps/v8/src/base/platform/mutex.h:131: error: expected ‘}’ before ‘public’ ../deps/v8/src/base/platform/mutex.h:131: error: expected ‘,’ or ‘;’ before ‘public’ ../deps/v8/src/base/platform/mutex.h:133: error: expected constructor, destructor, or type conversion before ‘;’ token ../deps/v8/src/base/platform/mutex.h:155: error: ‘Mutex’ has not been declared ../deps/v8/src/base/platform/mutex.h:155: error: expected initializer before ‘NativeHandle’ ../deps/v8/src/base/platform/mutex.h:157: error: expected constructor, destructor, or type conversion before ‘&’ token ../deps/v8/src/base/platform/mutex.h:160: error: expected initializer before ‘&’ token ../deps/v8/src/base/platform/mutex.h:164: error: expected unqualified-id before ‘private’ ../deps/v8/src/base/platform/mutex.h:170: error: expected unqualified-id before ‘const’ ../deps/v8/src/base/platform/mutex.h:170: error: expected ‘)’ before ‘const’ ../deps/v8/src/base/platform/mutex.h:170: error: ‘void v8::operator=(const v8::RecursiveMutex&)’ must be a nonstatic member function ../deps/v8/src/base/platform/mutex.h:184: error: expected initializer before ‘<’ token ../deps/v8/src/base/platform/mutex.h:202: error: template declaration of ‘LockGuard final’ ../deps/v8/src/base/platform/mutex.h:203: error: expected primary-expression before ‘public’ ../deps/v8/src/base/platform/mutex.h:203: error: expected ‘}’ before ‘public’ ../deps/v8/src/base/platform/mutex.h:205: error: declaration of ‘~LockGuard’ as non-member ../deps/v8/src/base/platform/mutex.h:207: error: expected unqualified-id before ‘private’ ../deps/v8/src/base/platform/mutex.h:210: error: expected unqualified-id before ‘const’ ../deps/v8/src/base/platform/mutex.h:210: error: expected ‘)’ before ‘const’ ../deps/v8/src/base/platform/mutex.h:210: error: ‘void operator=(const LockGuard&)’ must be a nonstatic member function ../deps/v8/src/base/platform/mutex.h:211: error: expected declaration before ‘}’ token make[1]: *** [/usr/local/src/node-v4.4.5/out/Release/obj.target/v8_base/deps/v8/src/accessors.o] Error 1 make[1]: Leaving directory `/usr/local/src/node-v4.4.5/out' make: *** [node] Error 2 [root@master node-v4.4.5]#
貌似GCC版本太低,需要升级到4.8版本以上
当前版本:
[root@master node-v4.4.5]# gcc -v Using built-in specs. Target: x86_64-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux Thread model: posix gcc version 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC) [root@master node-v4.4.5]#
升级参考:http://www.cnblogs.com/lzpong/p/5755678.html
升级成功:
[root@master ~]# gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.8.2/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../configure -enable-checking=release -enable-languages=c,c++ -disable-multilib Thread model: posix gcc version 4.8.2 (GCC) [root@master ~]#
make再次失败,提示 import bz2 失败,参考 http://www.111cn.net/sys/CentOS/62830.htm
./configure 失败 参考 http://blog.chinaunix.net/uid-26000296-id-4356738.html
接着make 失败
collect2: fatal error: cannot find 'ld' compilation terminated. make[1]: *** [/usr/local/src/node-v4.4.5/out/Release/mksnapshot] Error 1 make[1]: Leaving directory `/usr/local/src/node-v4.4.5/out' make: *** [node] Error 2
解决办法
./configure --prefix=/usr/local/node/4.4.5 --without-snapshot
重新make,过!继续按照安装文档改环境变量
查看版本,继续报错:
[root@master bin]# node -v node: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by node)
参考 http://www.cnblogs.com/weinyzhou/p/4983306.html 解决
[root@master lib64]# node -v v4.4.5 [root@master lib64]#
测试代码:
var http = require("http"); http.createServer(function(request, response) { response.writeHead(200, { "Content-Type" : "text/plain" // 输出类型 }); response.write("Hello World");// 页面输出 response.end(); }).listen(8100); // 监听端口号 console.log("nodejs start listen 8100 port!");