Centos 安装 NodeJS

1.并且安装一些Node.js的必要的包

yum -y install gcc make gcc-c++ openssl-devel wget

2.获取Node.JS的源代码

安装好依赖包之后我们可以从官方网站上下载的Node.js的源代码下载以及解压的命令如下:

wget https://nodejs.org/dist/v8.7.0/node-v8.7.0.tar.gz 

3.解压

tar zxvf node-v8.7.0.tar.gz

4.编译及安装:

进入解压完的文件夹里
例如:
cd node-v8.7.0
执行:
进入源代码的目录,然后运行./configure文件
./configure
 
 make install

 

结果:
installing /usr/local/lib/node_modules/npm/html/doc/files/npmrc.html
installing /usr/local/lib/node_modules/npm/html/doc/files/package-lock.json.html
installing /usr/local/lib/node_modules/npm/html/doc/files/npm-package-locks.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-prefix.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-doctor.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-owner.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-star.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-help-search.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-test.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-pack.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-cache.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-deprecate.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-bin.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-help.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-edit.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-whoami.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-repo.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-team.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-dist-tag.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-uninstall.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-rebuild.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-restart.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-unpublish.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-view.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-run-script.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-docs.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-link.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-dedupe.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-bundle.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-ping.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-search.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-ls.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-completion.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-install-test.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-update.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-access.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-prune.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-logout.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-start.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-shrinkwrap.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-publish.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-bugs.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-version.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-stars.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-init.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-outdated.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-build.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-root.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-explore.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-config.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-adduser.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-stop.html
installing /usr/local/lib/node_modules/npm/html/doc/cli/npm-install.html
installing /usr/local/lib/node_modules/npm/html/static/style.css
installing /usr/local/lib/node_modules/npm/html/static/toc.js
installing /usr/local/lib/node_modules/npm/.github/issue_template.md
installing /usr/local/lib/node_modules/npm/.github/CODEOWNERS
symlinking ../lib/node_modules/npm/bin/npm-cli.js -> /usr/local/bin/npm
symlinking ../lib/node_modules/npm/bin/npx-cli.js -> /usr/local/bin/npx
installing /usr/local/include/node/common.gypi
installing /usr/local/include/node/config.gypi
installing /usr/local/include/node/node.h
installing /usr/local/include/node/node_api.h
installing /usr/local/include/node/node_api_types.h
installing /usr/local/include/node/node_buffer.h
installing /usr/local/include/node/node_object_wrap.h
installing /usr/local/include/node/node_version.h
installing /usr/local/include/node/v8-util.h
installing /usr/local/include/node/v8-inspector.h
installing /usr/local/include/node/v8-inspector-protocol.h
installing /usr/local/include/node/v8config.h
installing /usr/local/include/node/v8-platform.h
installing /usr/local/include/node/v8-profiler.h
installing /usr/local/include/node/v8-version-string.h
installing /usr/local/include/node/v8-value-serializer-version.h
installing /usr/local/include/node/v8-testing.h
installing /usr/local/include/node/v8.h
installing /usr/local/include/node/v8-debug.h
installing /usr/local/include/node/v8-version.h
installing /usr/local/include/node/libplatform/v8-tracing.h
installing /usr/local/include/node/libplatform/libplatform-export.h
installing /usr/local/include/node/libplatform/libplatform.h
installing /usr/local/include/node/uv-linux.h
installing /usr/local/include/node/stdint-msvc2008.h
installing /usr/local/include/node/uv-threadpool.h
installing /usr/local/include/node/tree.h
installing /usr/local/include/node/uv-posix.h
installing /usr/local/include/node/uv-errno.h
installing /usr/local/include/node/uv-win.h
installing /usr/local/include/node/pthread-barrier.h
installing /usr/local/include/node/uv-bsd.h
installing /usr/local/include/node/uv.h
installing /usr/local/include/node/uv-unix.h
installing /usr/local/include/node/uv-sunos.h
installing /usr/local/include/node/uv-darwin.h
installing /usr/local/include/node/uv-os390.h
installing /usr/local/include/node/uv-aix.h
installing /usr/local/include/node/android-ifaddrs.h
installing /usr/local/include/node/uv-version.h
installing /usr/local/include/node/openssl/modes.h
installing /usr/local/include/node/openssl/pkcs12.h
installing /usr/local/include/node/openssl/buffer.h
installing /usr/local/include/node/openssl/whrlpool.h
installing /usr/local/include/node/openssl/camellia.h
installing /usr/local/include/node/openssl/opensslconf.h
installing /usr/local/include/node/openssl/kssl.h
installing /usr/local/include/node/openssl/rc2.h
installing /usr/local/include/node/openssl/ecdh.h
installing /usr/local/include/node/openssl/ssl23.h
installing /usr/local/include/node/openssl/ebcdic.h
installing /usr/local/include/node/openssl/blowfish.h
installing /usr/local/include/node/openssl/asn1t.h
installing /usr/local/include/node/openssl/idea.h
installing /usr/local/include/node/openssl/asn1.h
installing /usr/local/include/node/openssl/ui.h
installing /usr/local/include/node/openssl/x509_vfy.h
installing /usr/local/include/node/openssl/ts.h
installing /usr/local/include/node/openssl/pem.h
installing /usr/local/include/node/openssl/lhash.h
installing /usr/local/include/node/openssl/dh.h
installing /usr/local/include/node/openssl/srp.h
installing /usr/local/include/node/openssl/objects.h
installing /usr/local/include/node/openssl/safestack.h
installing /usr/local/include/node/openssl/bn.h
installing /usr/local/include/node/openssl/txt_db.h
installing /usr/local/include/node/openssl/dtls1.h
installing /usr/local/include/node/openssl/rand.h
installing /usr/local/include/node/openssl/ssl3.h
installing /usr/local/include/node/openssl/bio.h
installing /usr/local/include/node/openssl/x509.h
installing /usr/local/include/node/openssl/seed.h
installing /usr/local/include/node/openssl/crypto.h
installing /usr/local/include/node/openssl/cmac.h
installing /usr/local/include/node/openssl/sha.h
installing /usr/local/include/node/openssl/ssl.h
installing /usr/local/include/node/openssl/krb5_asn.h
installing /usr/local/include/node/openssl/ripemd.h
installing /usr/local/include/node/openssl/rc4.h
installing /usr/local/include/node/openssl/rsa.h
installing /usr/local/include/node/openssl/md4.h
installing /usr/local/include/node/openssl/pem2.h
installing /usr/local/include/node/openssl/e_os2.h
installing /usr/local/include/node/openssl/ssl2.h
installing /usr/local/include/node/openssl/evp.h
installing /usr/local/include/node/openssl/conf_api.h
installing /usr/local/include/node/openssl/obj_mac.h
installing /usr/local/include/node/openssl/err.h
installing /usr/local/include/node/openssl/des.h
installing /usr/local/include/node/openssl/pkcs7.h
installing /usr/local/include/node/openssl/cms.h
installing /usr/local/include/node/openssl/md5.h
installing /usr/local/include/node/openssl/ec.h
installing /usr/local/include/node/openssl/srtp.h
installing /usr/local/include/node/openssl/dsa.h
installing /usr/local/include/node/openssl/stack.h
installing /usr/local/include/node/openssl/dso.h
installing /usr/local/include/node/openssl/ocsp.h
installing /usr/local/include/node/openssl/hmac.h
installing /usr/local/include/node/openssl/pqueue.h
installing /usr/local/include/node/openssl/conf.h
installing /usr/local/include/node/openssl/ecdsa.h
installing /usr/local/include/node/openssl/opensslv.h
installing /usr/local/include/node/openssl/engine.h
installing /usr/local/include/node/openssl/ui_compat.h
installing /usr/local/include/node/openssl/des_old.h
installing /usr/local/include/node/openssl/ossl_typ.h
installing /usr/local/include/node/openssl/cast.h
installing /usr/local/include/node/openssl/aes.h
installing /usr/local/include/node/openssl/symhacks.h
installing /usr/local/include/node/openssl/x509v3.h
installing /usr/local/include/node/openssl/tls1.h
installing /usr/local/include/node/openssl/asn1_mac.h
installing /usr/local/include/node/openssl/comp.h
installing /usr/local/include/node/openssl/mdc2.h
installing /usr/local/include/node/openssl/archs/VC-WIN64A/opensslconf.h
installing /usr/local/include/node/openssl/archs/linux32-s390x/opensslconf.h
installing /usr/local/include/node/openssl/archs/BSD-x86/opensslconf.h
installing /usr/local/include/node/openssl/archs/solaris-x86-gcc/opensslconf.h
installing /usr/local/include/node/openssl/archs/linux-ppc/opensslconf.h
installing /usr/local/include/node/openssl/archs/linux-armv4/opensslconf.h
installing /usr/local/include/node/openssl/archs/linux-ppc64/opensslconf.h
installing /usr/local/include/node/openssl/archs/darwin64-x86_64-cc/opensslconf.h
installing /usr/local/include/node/openssl/archs/linux-x86_64/opensslconf.h
installing /usr/local/include/node/openssl/archs/linux-elf/opensslconf.h
installing /usr/local/include/node/openssl/archs/aix-gcc/opensslconf.h
installing /usr/local/include/node/openssl/archs/linux64-s390x/opensslconf.h
installing /usr/local/include/node/openssl/archs/linux-aarch64/opensslconf.h
installing /usr/local/include/node/openssl/archs/darwin-i386-cc/opensslconf.h
installing /usr/local/include/node/openssl/archs/solaris64-x86_64-gcc/opensslconf.h
installing /usr/local/include/node/openssl/archs/BSD-x86_64/opensslconf.h
installing /usr/local/include/node/openssl/archs/aix64-gcc/opensslconf.h
installing /usr/local/include/node/openssl/archs/linux-x32/opensslconf.h
installing /usr/local/include/node/openssl/archs/VC-WIN32/opensslconf.h
installing /usr/local/include/node/openssl/opensslconf.h
installing /usr/local/include/node/zconf.h
installing /usr/local/include/node/zlib.h

执行:

[root@202ce21f6739 node-v8.7.0]# node -v
和 npm -v

结果

v8.7.0

 如果npm不管用,请执行

make install npm 或者curl -L https://www.npmjs.com/install.sh | sh

  

 https://www.cnblogs.com/fazero/p/5910717.html

http://blog.csdn.net/xerysherryx/article/details/78920978

posted @ 2018-02-25 12:02  开始战斗  阅读(204)  评论(0编辑  收藏  举报