apt update
apt install nodejs npm -y
npm config set registry http://registry.npm.taobao.org/
# 默认安装源
npm config set registry https://registry.npmjs.org/
npm i express express-generator -g
mkdir proj
cd proj
npm init
npm i express --save
按照国际惯例 先写一个 “Hello world!”
nano app.js
贴入以下内容,并保存
var express = require('express');
var app = express();
app.get('/', function (req, res) {
res.send('Hello World!');
});
app.listen(3000, function () {
console.log('app is running at http://127.0.0.1:3000');
});
运行
node app
浏览器访问:http://127.0.0.1:3000
© 2020 飞鱼的博客