1.安装
$ npm install express --save
2.index.js
const express = require('express') const app = express() app.get('/', (req, res) => res.send('Hello World!')) app.listen(3000, () => console.log('Example app listening on port 3000!'))
3.Express 应用程序生成器
官网教程执行npm install express-generator -g
控制台会提示The program 'express' is currently not installed. You can install it by typing:
apt-get install node-express
改用命令
apt-get install node-express express --version //查看版本 express --view==pug myapp //app目录下生成一个项目目录 cd myapp //进入目录 npm i //安装依赖 node app //运行项目
浏览器输入 host:3000,报错`!!!` is deprecated, you must now use `doctype`
views/layout.jade
第一行把!!!
改为doctype