admin管理员组文章数量:1279120
I believe nodemon is supposed to watch all directories for changes by default (expect for node_module, etc).
nodemon /bin/www 3000
But it's only monitoring changes to files in the root folder.
nodemon /bin/www 3000
[nodemon] 1.9.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node ./bin/www /bin/www 3000`
How can I specify that it watch all folders in the project?
I believe nodemon is supposed to watch all directories for changes by default (expect for node_module, etc).
nodemon /bin/www 3000
But it's only monitoring changes to files in the root folder.
nodemon /bin/www 3000
[nodemon] 1.9.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node ./bin/www /bin/www 3000`
How can I specify that it watch all folders in the project?
Share Improve this question edited Apr 9, 2016 at 9:26 BAR asked Apr 9, 2016 at 9:10 BARBAR 17.1k27 gold badges106 silver badges204 bronze badges2 Answers
Reset to default 7By default nodemon monitors the current working directory. If you want to take control of that option, use the --watch
option to add specific paths:
nodemon --watch app --watch libs /bin/www 3000
Check official documentation: here.
Nodemon by default watches all directories in the project, but detects only changes in javascript files.
You can add the following watch script to package.json
file and it will automatically restart the script on any file change:
"scripts": {
"start": "node ./bin/www",
"watch": "nodemon ./bin/www --watch ./ --ext '*' localhost 3000"
}
the first argument here is the express server path that nodemon is supposed to restart/ run on any file change, the second is the file extensions which nodemon is supposed to watch changes on it, and the last two are the host and port on which your server is running.
Now, you can run:
$ npm run watch
and it should be working.
It is remended to add the nodemon as development dependency rather than a main/ build one as follows:
"devDependencies": {
"nodemon": "^2.0.12"
},
"dependencies": {
}
本文标签: javascriptNodemon watch all project directoriesStack Overflow
版权声明:本文标题:javascript - Nodemon watch all project directories - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741218856a2360573.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论