尝试后可以成功在Ubuntu安装node.js的方法
2017-07-07 10:26
561 查看
步骤1: 用curl获取源代码
在我们用curl获取源代码之前,我们必须先升级操作系统,然后用curl命令获取NodeSource添加到本地仓库。root@ubuntu-15:~#apt-get update
root@ubuntu-15:~# curl-sL https://deb.nodesource.com/setup | sudo bash -
curl将运行以下任务
## Installing the NodeSource Node.js 0.10 repo...
## Populating apt-get cache...
## Confirming "vivid" is supported...
## Adding the NodeSource signing key to your keyring...
## Creating apt sources list file for the NodeSource Node.js 0.10 repo...
## Running `apt-get update` for you...
Fetched6,411 Bin5s(1,077 B/s)
Readingpackage lists...Done
## Run `apt-get install nodejs` (as root) to install Node.js 0.10 and npm
步骤2: 安装NodeJS和NPM
运行以上命令之后如果输出如上所示,我们可以用apt-get命令来安装NodeJS和NPM包。root@ubuntu-15:~# apt-get install nodejs
NodeJS Install
步骤3: 安装一些必备的工具
通过以下命令来安装编译安装一些我们必需的本地插件。root@ubuntu-15:~# apt-get install-y build-essential
敲入node命令,结果发现不行,提示是否要运行:apt-get install nodejs-********
按照提示执行,完成!
通过Node.JS Shell来测试
测试Node.JS的步骤与之前使用源代码安装相似,通过以下node命令来确认Node.JS是否完全安装好:root@ubuntu-15:~# node
> console.log('Node.js Installed Using Package Manager');
Node.jsInstalledUsingPackageManager
root@ubuntu-15:~# node
> a =[1,2,3,4,5]
[1,2,3,4,5]
>typeof a
'object'
>5+2
7
>
(^C again to quit)
>
root@ubuntu-15:~#
使用NodeJS应用进行简单的测试
REPL是一个Node.js的shell,任何有效的JavaScript代码都能在REPL下运行通过。所以让我们看看在Node.JS下的REPL是什么样子吧。root@ubuntu-15:~# node
>var repl=require("repl");
undefined
> repl.start("> ");
PressEnterand it will showout put like this:
>{ domain:null,
_events:{},
_maxListeners:10,
useGlobal:false,
ignoreUndefined:false,
eval:[Function],
inputStream:
{ _connecting:false,
_handle:
{ fd:0,
writeQueueSize:0,
owner:[Circular],
onread:[Function: onread],
reading:true},
_readableState:
{ highWaterMark:0,
buffer:[],
length:0,
pipes:null,
...
...
以下是可以在REPL下使用的命令列表
REPL Manual
相关文章推荐
- Ubuntu 11.10 安装Node.js的方法
- Ubuntu16.10 下安装node.js提示./configure 权限不够的解决方法
- Ubuntu 11.10 安装Node.js的方法
- Ubuntu 11.10 安装Node.js的方法
- MyEclipse8.6安装SVN插件的方法(多次尝试后成功)
- 在Windows上安装Node.js模块的方法
- Ubuntu安装node.js
- 在Ubuntu 上安装node.js
- ubuntu 12.04 安装 node.js
- MyEclipse8.6安装SVN插件的方法(多次尝试后成功)
- 在Ubuntu服务器上安装Node.js
- ubuntu 11.10 安装oracle 10g 成功步骤及问题解决方法
- 在Windows上安装Node.js模块的方法
- node.js在Ubuntu 12.04下的安装和配置
- node.js最省心的安装方法
- Ubuntu上安装Nodejs/ZeroMQ/MySQL
- Ubuntu 安装node.js
- Ubuntu 11.10 安装Node.js
- 如何在ubuntu上安装node.js
- 如何在ubuntu上安装node.js