• nodemon


    nodemon是一种工具,可在检测到目录中的文件更改时通过自动重新启动节点应用程序来帮助开发基于node.js的应用程序

    在编写调试Node.js项目,修改代码后,需要重新启动

    为了减轻手工重启的成本,可以采用 nodemon 来代替 node 以启动应用。当代码发生变化时候,nodemon 会帮我们自动重启

    安装

    npm install -g nodemon

    查看

    $ nodemon -h
      Usage: nodemon [options] [script.js] [args]
    
      Options:
    
      --config file ............ alternate nodemon.json config file to use
      -e, --ext ................ extensions to look for, ie. js,pug,hbs.
      -x, --exec app ........... execute script with "app", ie. -x "python -v".
      -w, --watch path ......... watch directory "path" or files. use once for
                                 each directory or file to watch.
      -i, --ignore ............. ignore specific files or directories.
      -V, --verbose ............ show detail on what is causing restarts.
      -- <your args> ........... to tell nodemon stop slurping arguments.
    ……

    eg:

    $ nodemon app
    [nodemon] 2.0.4
    [nodemon] to restart at any time, enter `rs`
    [nodemon] watching path(s): *.*
    [nodemon] watching extensions: js,mjs,json
    [nodemon] starting `node app.js`
    mongodb://127.0.0.1:27017/traptor
    Example app listening on port 3000!
    数据库链接成功!

    调用的也是node命令

    修改代码保存后后,会自动重启

    手动重启,也不用停掉重启,使用

    rs

    指定内存使用大小的启动

    $ nodemon --max-old-space-size=2048 app.js
    [nodemon] 2.0.4
    [nodemon] to restart at any time, enter `rs`
    [nodemon] watching path(s): *.*
    [nodemon] watching extensions: js,mjs,json
    [nodemon] starting `node --max-old-space-size=2048 app.js`
    mongodb://127.0.0.1:27017/traptor
    Example app listening on port 3000!
    数据库链接成功!

     注:

      git-bash使用ctrl+c无法终止nodemon的执行,可以使用

     netstat -aon|findstr "3000"

      查出进程id,终止进程

    tskill 进程id

      使用CMD窗口ctrl+c可以终止执行

  • 相关阅读:
    x264
    [转贴]使用dbstart 和dbshut 脚本来自动化启动和关闭数据库
    企业搜索引擎开发之连接器connector(二十六)
    企业搜索引擎开发之连接器connector(二十五)
    深入分析 Java 中的中文编码问题
    深入分析 Java I/O 的工作机制
    企业搜索引擎开发之连接器connector(二十四)
    企业搜索引擎开发之连接器connector(二十三)
    企业搜索引擎开发之连接器connector(二十二)
    企业搜索引擎开发之连接器connector(二十一)
  • 原文地址:https://www.cnblogs.com/baby123/p/13728546.html
Copyright © 2020-2023  润新知