install nodejs centos

sources : [原文檔鏈接]

1 download nojs install package
link : https://nodejs.org/dist/v5.10.1/
2 according to system’s kernal to download the right version
as follows

3 config your system variables

the details as follows to see sources

(一) 編譯好的文件

  像上圖中紅色框裏面的就是已經編譯好的文件,選擇好對應的linux版本下載即可,簡單說就是解壓後,在bin文件夾中已經存在node以及npm,如果你進入到對應文件的中執行命令行一點問題都沒有,不過不是全局的,所以通過建立軟鏈接的方式將這個設置爲全局就好了。

tar xf node-v5.10.1-linux-x64.tar.gz -C /usr/local/
cd /usr/local/
mv node-v5.10.1-linux-x64/ nodejs
ln -s /usr/local/nodejs/bin/node /usr/local/bin
ln -s /usr/local/nodejs/bin/npm /usr/local/bin
(二)通過源碼編譯

這種方式你下載的文件是Source code,由於我的linux版本是6.x的,默認的gcc-c++爲4.4.7 版本,而下過來之後源碼編譯要求gcc-c++版本最低爲4.8,於是我就去升級GCC-C++版本,結果因爲是源碼編譯升級GCC-C++,編譯了一個多小時,都沒有編譯完成!果斷被坑...

root># ./configure
WARNING: C++ compiler too old, need g++ 4.8 or clang++ 3.4 (CXX=g++)
creating ./icu_config.gypi
{ ‘target_defaults’: { ‘cflags’: [],
‘default_configuration’: ‘Release’,
‘defines’: [],
‘include_dirs’: [],
‘libraries’: []},
‘variables’: { ‘asan’: 0,
‘gas_version’: ‘2.20’,
‘host_arch’: ‘x64’,
‘icu_small’: ‘false’,
‘node_byteorder’: ‘little’,
‘node_install_npm’: ‘true’,
‘node_prefix’: ‘/usr/local’,
‘node_release_urlbase’: ”,
‘node_shared_http_parser’: ‘false’,
‘node_shared_libuv’: ‘false’,
‘node_shared_openssl’: ‘false’,
‘node_shared_zlib’: ‘false’,
‘node_tag’: ”,
‘node_use_dtrace’: ‘false’,
‘node_use_etw’: ‘false’,
‘node_use_lttng’: ‘false’,
‘node_use_openssl’: ‘true’,
‘node_use_perfctr’: ‘false’,
‘openssl_fips’: ”,
‘openssl_no_asm’: 0,
‘target_arch’: ‘x64’,
‘uv_parent_path’: ‘/deps/uv/’,
‘uv_use_dtrace’: ‘false’,
‘v8_enable_gdbjit’: 0,
‘v8_enable_i18n_support’: 0,
‘v8_no_strict_aliasing’: 1,
‘v8_optimized_debug’: 0,
‘v8_random_seed’: 0,
‘v8_use_snapshot’: ‘true’,
‘want_separate_host_toolset’: 0}}
creating ./config.gypi
creating ./config.mk
WARNING: warnings were emitted in the configure phase
(三)apt-get

還有一種就是烏班圖下的apt-get方式,我之前就被這種方式坑了

  sudo apt-get install nodejs
  sudo apt-get install npm
這麼裝完你會發現,node命令不好使,nodejs命令可以用…

發佈了47 篇原創文章 · 獲贊 6 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章