node start

Write a file t1.js

'use strict';

const express = require('express');

// Constants
const PORT = 8080;

// App
const app = express();
app.get('/', function (req, res) {
  res.send('Hello world
');
});

app.listen(PORT);
console.log('Running on http://localhost:' + PORT);

运行

node t1.js

在浏览器输入

http://localhost:8080/

 
原文地址:https://www.cnblogs.com/cutepig/p/5655606.html