I know how to do nodemon server.js
but what if I want to do nodemon ./src
I want restart node on any changes in the directory of src
.
When I do above and it say cannot find module babelprac\src
I am also doing in another command window : npm run scripts:watch
The script is
"scripts" : { "scripts" : "babel src --source-maps-inline --out-dir dist", "scripts:watch" : "babel src --watch --source-map-inline --out-dir dist" },
That runs the watch but I want to run the script in src or dist to see the console.logs
I aslo tried nodemon --watch ./src
. It says it can't find index.js.
I am on windows 7
My working directory is babelprac
nodemon will watch the files in the directory that nodemon was started, and if they change, it will automatically restart your node application. nodemon does not require any changes to your code or method of development. nodemon simply wraps your node application and keeps an eye on any files that have changed.
Note that by default, nodemon will ignore the . git and node_modules/**/node_modules directories.
From the official documentation and github page: nodemon supports local and global configuration files. These are usually named nodemon. json and can be located in the current working directory or in your home directory.
Nodemon expects it just as:
nodemon --watch src server.js
https://github.com/remy/nodemon#monitoring-multiple-directories
nodemon --watch app --watch libs app/server.js
Nodemon also has a more fine-grained approach for watching folders and files. Use nodemon.json
to specify what files and the types of files to watch, as below in your case:
{ "watch": ["server.js", "src/"], "ext": "js, css" }
Having a nodemon.json
is particularly useful when the number and types of watched files start to bloat, and also when you want to run a script upon each server restart. For nodemon to read in the configuration, nodemon.json
should be placed at the root directory of your project, along with every other hidden and not hidden json files.
Below is a good place to start your nodemon.json
.
https://github.com/remy/nodemon/blob/master/doc/sample-nodemon.md
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With