尝试后可以成功在Ubuntu安装node.js的方法
来源:互联网 发布:淘宝机票平台出租 编辑:程序博客网 时间:2024/05/20 20:04
步骤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 likethis:
>{ 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
阅读全文
0 0
- 尝试后可以成功在Ubuntu安装node.js的方法
- 在ubuntu 安装node.js
- MyEclipse8.6安装SVN插件的方法(多次尝试后成功)
- MyEclipse8.6安装SVN插件的方法(多次尝试后成功)
- MyEclipse8.6安装SVN插件的方法(多次尝试后成功)
- node.js在Ubuntu 12.04下的安装和配置
- 在Ubuntu上安装node.js的一个经历
- node.js在Ubuntu 12.04下的安装和配置
- 如何在Ubuntu上安装最新版本的Node.js
- node.js在Ubuntu 12.04下的安装和配置
- node.js在Ubuntu 12.04下的安装和配置
- 如何在Ubuntu上安装最新版本的Node.js
- 在Ubuntu上安装Node.js的Upstream版本
- 如何在Ubuntu上安装最新版本的Node.js
- 如何在Ubuntu上安装最新版本的Node.js
- 如何在Ubuntu上安装最新版本的Node.js
- 在Ubuntu 上安装node.js
- 如何在ubuntu上安装node.js
- 【微信小程序】发送消息模板教程
- 一个java文件中可以有多个类
- redis支持的数据类型、操作指令及使用场景
- python入门系列20―——GUI Tkinter入门
- 【Centos7笔记七】用户及文件权限管理
- 尝试后可以成功在Ubuntu安装node.js的方法
- 源码日记——ArrayList
- JS中的prototype
- 用GDB调试程序
- 区块链技术运用在票据领域-票据链
- 分针网——每日分享:Vue计算属性
- 初见Java多线程(一、线程的概念)
- thinkphp的无刷新分页
- 【ubuntu】各个版本镜像下载地址