nodemon 直接将结果存储在内存中
nodemon
具体的文件名。如果什么都不指明,使用package.json
的 main 字段rs
。 重启nodemon.json
。配置文件,可以放到当前工作目录或者 home 目录下面。也可以使用--config file
来指定自定义的文件- 如果想把配置放到
package.json
里面,可以放到nodemonConfig
这个字段下面。如果指定了--config file
或者有nodemon.json
那么package.json
的配置不会生效 - 可以同来监听其他应用程序。
nodemon --exec "python -v" ./app.py
, 这段代码表示 nodemon 会监听./app.py
并再其发生变动的时候执行python -v ./app.py
如果 需要带上选项,那么被监听的程序应该带上引号 - 可以再 nodemon.json 配置文件中配置,当执行某个文件,类型的时候,使用什么去执行
{
"execMap": {
"ts": "ts-node" // 当执行 nodemon index.ts 时,会使用 ts-node 去执行改文件类型
}
}
nodemon --watch app --watch libs app/server.js
监听多个文件夹, 注意不要使用正则表达式nodemon -e js,pug
指定监听的文件扩展名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"
}