一.什么是Node.js

  Node.js是一个基于Chrome JavaScript运行时建立的平台,用于方便地搭建响应速度快、易于扩展的网络应用。Node.js 使用事件驱动, 非阻塞I/O模型而得以轻量和高效,非常适合在分布式设备上运行数据密集型的实时应用。

二.起因

        由于其特性所以有很多应用是使用Node.js开发的,这次我想用的某个爬虫就是Node.js应用,所以我只能去研究下怎么安装了,看了下网上一堆教程,唯一的感觉是这货版本真的多……作为一个选择强迫症,纠结装哪个版本是痛苦的,直到我发现了NVM——Node Version Manager,一个能够方便安装并管理(切换)Node.js的神器,从此我想切哪个版本切哪个233。

三.安装步骤

        参照其github的readme,安装nvm基本上是一键的

Install script

To install or update nvm, you can use the install script using cURL:

or Wget:

The script clones the nvm repository to ~/.nvm and adds the source line to your profile (~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc).

 

最后一部分的环境变量设置脚本也完成了,一般不用你去手动执行,我们只需稍等片刻然后关闭ssh窗口并重新打开就能执行nvm命令了 sp160829_165336

Usage

To download, compile, and install the latest release of node, do this:

And then in any new shell just use the installed version:

Or you can just run it:

Or, you can run any arbitrary command in a subshell with the desired version of node:

You can also get the path to the executable to where it was installed:

这些是基本的命令,更加详细的可以执行nvm --help来查看。目前Node.js的最新版本是6.4.0,所以我们可以执行nvm install 6.4.0来安装,一切,就是这么简单。


Senraの小窝原创文章,转载请注明来自:Centos下使用nvm安装管理node.js