---
# System prepended metadata

title: Node必學框架 - Express
tags: [node.js]

---

---
title: Node必學框架 - Express
tags: node.js
---

# Node必學框架 - Express

安裝方式 npm install express

const express = require('express');
const app = express();

//json parser
app.use(express.json());

app.get('/', (req, res) => { 
    res.send('Hello World!')
})

app.listen(5000, () => {
  console.log("Listening to port: 5000")
})

http://localhost:5000 顯示Hello World!!

![](https://i.imgur.com/N27f3g8.jpg)


## Deploy to heroku
```
const express = require('express');
const app = express();

//json parser
app.use(express.json());

app.get('/', (req, res) => { 
    res.send('Hello World!')
})

const port = process.env.PORT || 5000;

app.listen(5000, () => {
  console.log(`Listening to port: ${port}`)
})
```


