nodemon使用方法

nodemon 直接将结果存储在内存中

  1. nodemon 具体的文件名。如果什么都不指明,使用 package.json 的 main 字段
  2. rs。 重启
  3. nodemon.json。配置文件,可以放到当前工作目录或者 home 目录下面。也可以使用 --config file 来指定自定义的文件
  4. 如果想把配置放到 package.json 里面,可以放到 nodemonConfig 这个字段下面。如果指定了 --config file 或者有 nodemon.json 那么 package.json 的配置不会生效
  5. 可以同来监听其他应用程序。nodemon --exec "python -v" ./app.py, 这段代码表示 nodemon 会监听 ./app.py 并再其发生变动的时候执行 python -v ./app.py 如果 需要带上选项,那么被监听的程序应该带上引号
  6. 可以再 nodemon.json 配置文件中配置,当执行某个文件,类型的时候,使用什么去执行
{
   "execMap": {
   "ts": "ts-node" // 当执行 nodemon index.ts 时,会使用 ts-node 去执行改文件类型
 }
}
  1. nodemon --watch app --watch libs app/server.js 监听多个文件夹, 注意不要使用正则表达式
  2. nodemon -e js,pug 指定监听的文件扩展名
  3. nodemon --ignore lib/ --ignore tests/nodemon --ignore 'lib/*.js' 忽略文件
    10.nodemon --delay 10 server.js 延迟 10 秒
// 默认配置项
module.exports = {
  restartable: 'rs',
  colours: true,
  execMap: {
    py: 'python',
    rb: 'ruby',
    ts: 'ts-node',
    // more can be added here such as ls: lsc - but please ensure it's cross
    // compatible with linux, mac and windows, or make the default.js
    // dynamically append the `.cmd` for node based utilities
  },
  ignoreRoot: ignoreRoot.map(_ => `**/${_}/**`),
  watch: ['*.*'],
  stdin: true,
  runOnChangeOnly: false,
  verbose: false,
  signal: 'SIGUSR2',
  // 'stdout' refers to the default behaviour of a required nodemon's child,
  // but also includes stderr. If this is false, data is still dispatched via
  // nodemon.on('stdout/stderr')
  stdout: true,
  watchOptions: {

  },
};
// 一些其他方式的配置项
{
  "restartable": "rs",
  "ignore": [
    ".git",
    "node_modules/**/node_modules"
  ],
  "verbose": true,
  "execMap": {
    "js": "node --harmony"
  },
  "events": {
    "restart": "osascript -e 'display notification \"App restarted due to:\n'$FILENAME'\" with title \"nodemon\"'"
  },
  "watch": [
    "test/fixtures/",
    "test/samples/"
  ],
  "env": {
    "NODE_ENV": "development"
  },
  "ext": "js,json"
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值