---
title: "Express Hello World"
author: "fairy_xzc"
date: "2017-01-10T16:09:42Z"
tags: []
categories: ["Web前端"]
slug: "express-hello-world"
draft: false
lastmod: "2017-01-10T16:10:13Z"
id: 2352259
url: "https://agilestyle.iteye.com/blog/2352259"
---

**原创转载请注明出处：[http://agilestyle.iteye.com/blog/2352259](/blog/2352259)**

 

## npm init

![](http://dl2.iteye.com/upload/attachment/0122/5117/e42a473c-8e37-3ed6-b6c9-24fac10ce661.png)  
 

## Install Express

```
npm install express --save --registry=https://registry.npm.taobao.org
```

![](http://dl2.iteye.com/upload/attachment/0122/5119/af572144-9126-37a2-a43c-7c5029e9a724.png)  
 

## Hello World

```
var express = require("express");
var app = express();

app.get("/", function (req, res) {
	res.send("Hello World");
});

var server = app.listen(8888, function () {
	var host = server.address().address;
	var port = server.address().port;

	console.log('Listening on address %s', host);
	console.log('Listening on port %d', port);
});
```

**Run**

![](http://dl2.iteye.com/upload/attachment/0122/5121/f7e8d1a3-f95e-311c-8e82-9c2f3b095f9b.png)

**Show**

![](http://dl2.iteye.com/upload/attachment/0122/5123/53d424c8-52e8-364f-a259-cbb7e7d9c749.png)