
上QQ阅读APP看书,第一时间看更新
2.4 树莓派3下使用NVM安装Node.js
树莓派是一款卡片式的学习电脑,由英国剑桥大学在2012年3月首发。本节主要介绍如何在树莓派3的官方操作系统Raspbian上使用NVM安装Node.js。
(1)首先下载和安装NVM(https://github.com/creationix/nvm)。NVM的全称是Node Version Manager(Node.js版本管理器),它可以让我们在各个Node.js版本之间进行灵活的切换。

(2)然后使用nano命令编辑.bashrc和.profile,在文件末尾增加source ~/.nvm/nvm.sh,并重新启动树莓派,具体命令如下:

(3)启动完成后,在shell里面执行nvm命令。当看到输出时,表示NVM安装成功。

(4)现在开始安装Node.js。使用nvm命令安装Node.js稳定版,如v0.12.3。

(5)安装完成后,可以使用下列代码进行查看。

这时可以看到自己安装的所有Node.js版本。