express-新建-响应与请求

1.新建文件夹

2.初始化项目,导入express

yarn init -y
yarn add express

3.在文件夹中新建server.js

const express = require('express')

const app = express()


app.get('/',function(req,res){ //响应路由
  let responseObject={
    name:'qiuzhiqiuiu'
  }
  res.send('hello  express')
})

app.listen(3000,()=>console.log('app has running on prot 3000')) //在3000端口

4.导入nodemon

yarn global add nodemon

5.运行

nodemon server.js
原文地址:https://www.cnblogs.com/lxz-blogs/p/14046460.html