1-1在本地构建项目

  1. ****终端
  2. yarn init -y
  3. yarn add koa koa-router
  1. const koa = require("koa");
  2. const app = new koa();
  3. const router = require("koa-router")();
  4. router.get("/",async ctx=>{
  5. ctx.body="hello world"
  6. })
  7. app.use(router.routes());
  8. app.listen(8080)

1-2 上传项目

四、上传node项目到linux - 图1

1-3 启动项目

cd /home/hello  #  读取对于文件夹
yarn #  安装依赖
cnpm i nodemon -g
nodemon index.js

1-4 打开所在端口


02.png

image.png
04.png