• 跟我一起从零开始一个预告片电影网站(一)


    大家好呀,很久没有见啦,我的博客也写得少啦我也不够努力啦
    一寸光阴一寸金,我们一起加油,不断进步呀
    第一步

    mkdir douban-trailer-imooc
    cd douban-trailer-imooc
    

    第二步跟我一起在git中输入

    npm init
    

    记得比较重要的地方是

    entry point: (index.js) server/index.js
    

    第三步

     mkdir server
    cd server
    touch index.js
    
    //server/index.js
    const Koa = require('koa')
    const app = new Koa()
    app.use(async(ctx,next)=>{
        ctx.body = '电影首页'
    })
    app.listen(4455)
    

    接下来安装koa

     npm install koa@latest -S
    

    本来可以使用node server/index.js运行项目 但是是很长的一串,我们可以在package.json中修改命令

    //package.json
    {
      "name": "douban-trailer-imooc",
      "version": "1.0.0",
      "description": "",
      "main": "server/inder.js",
      "scripts": {
        "start": "node server/index.js",
        "test": "echo "Error: no test specified" && exit 1"
      },
      "keywords": [
        "movie",
        "trailer"
      ],
      "author": "dimple",
      "license": "ISC",
      "dependencies": {
        "koa": "^2.11.0"
      }
    }
    

    运行

    npm start
    

  • 相关阅读:
    Linux里的2>&1究竟是什么
    表锁操作
    日志rsyslog
    计划任务at cron
    rpm包管理和源码包管理
    自建yum源(只演示nginx服务,其它都一样)
    软件包管理yum
    文件打包及压缩
    查找文件which locate find
    lsof恢复进程打开的文件
  • 原文地址:https://www.cnblogs.com/smart-girl/p/12505586.html
Copyright © 2020-2023  润新知