1-1 在本地构建代码

  1. yarn init -y
  2. 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 上传项目

2.上传node项目到Linux - 图1

1-3 启动项目

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

1-4 打开8080端口

2.上传node项目到Linux - 图22.上传node项目到Linux - 图3
2.上传node项目到Linux - 图4