zoukankan      html  css  js  c++  java
  • express+nodemon 修改后浏览器自动刷新

    添加nodemon模块

    cnpm install --save nodemon

    根目录添加文件 nodemon.json

    {
        "restartable": "rs", 
        "ignore": [
            ".git",
            ".svn",
            "node_modules/**/node_modules"
        ],
        "verbose": true,
        "execMap": {
            "js": "node --harmony"
        },
        "watch": [
    
        ],
        "env": {
            "NODE_ENV": "development"
        },
        "ext": "js json njk css js "
    }

    express 修改内容后自动更新(免重启)

    entrance.js内容

    const express = require("express"),
      app = express(),
      debug = require('debug')('my-application'); // debug模块
    
    app.all("*", function (req, res, next){
        res.send('fdssc')
    })
    
    
    
    app.set('port', process.env.PORT || 9000); // 设定监听端口
    const server = app.listen(app.get('port'), function () {//启动监听
      debug('Express server listening on port ' + server.address().port);
    });

    package.json添加

    "scripts": {
    "dev":"nodemon entrance.js"
    }

    执行启动 cnpm run dev

  • 相关阅读:
    Circular vector
    【杂题】进制转换
    【POJ】3006
    【POJ】1503
    【POJ】2262
    【POJ】1083
    【POJ】2739
    对拍
    【POJ】2159
    【POJ】3299
  • 原文地址:https://www.cnblogs.com/lmyt/p/10160057.html
Copyright © 2011-2022 走看看