node.js第三方依赖包(后续有更新)

182 阅读1分钟

node.js第三方依赖包

  • 1.热启动工具 (全局依赖包)

    /*
        作用: 程序改变 不用重启程序或者刷新页面 自动更新使用新程序执行
                
        下载命令: npm i -g nodemon 
                (下载 nodemon 作为 全局依赖包)
        使用: 使用 nodemon 作为 运行命令 运行 nodejs 的 外部文件
    */
    
  • 2.时间格式转化的依赖包 (项目依赖)

    /*
        作用: 进行时间格式的转化
        下载命令: npm i moment
        网址: http://rank.chinaz.comwww.qdxiaochuan.com/?id=66
    */
    ​
    ​
    // 导入时间格式依赖包
      const moment = require('moment');
      // 设置为中文
      moment.locale('zh-cn');
    ​
      // 在server上添加中间件
      server.use((request, response,next) => {
       // 创建时间对象
       const time = new Date()     
       // fs.appendFile在文件末尾新增写入
       fs.appendFile('./readme.txt',`网址:${request.url} 时间:${moment(time).format('lll')}\n`,()=>{})
           next()
        })