Looks like when I do fs.writeFile(), the changed file restarts nodemon. How to make it not restart?
Asked Answered
P

2

19

I thinks what is happening is that for a callback to update a collection in mongoose I do a writeFile to all.json and I think that is causing my nodemon to restart.

The cmd window:

file saved
[nodemon] restarting due to changes...
{ ok: 1, nModified: 0, n: 1 }
Anon user added to doc
{ ok: 1, nModified: 1, n: 1 }
[nodemon] starting `node server.js`
listenting on port: 3000

I don't want it to restart when all.json changes.

I get a new session when it restarts and I want to do stuff with that session while developing. I don't want to use mongo-store or session store right now. I just don't want node to restart or get a new session but I want to fix it without playing around with the session parameters.

So please confirm that because the all.json file changes that is why nodemon restarts . I know that it doesn't restart for jade or ejs files but I didn't know about json

Also please suggest a solution.

Purposeless answered 13/7, 2016 at 22:13 Comment(1)
use --ignore. github.com/remy/nodemon#ignoring-filesHuddersfield
C
46

Add the name/s of the file/s you're creating to a file called nodemon.json, and place it at the root of your working folder:

{
  "ignore": ["*.test.txt", "myfiles/*"]
}

See other options here.

Coterminous answered 13/7, 2016 at 22:18 Comment(2)
Trailing comma should be removedHax
@TravellingTechGuy, is there any reason why this should not be working for NodeJS running an electron app? I placed the file where the package.json file is (at the root of the working directory) and although the directory with the file that will change is included, the reset of the app based upon that file change still takes placeChestonchest
A
3

if you want that nodemon will not watch json file you can use also --ext js on start script

Andradite answered 15/12, 2020 at 9:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.