Answer the question
In order to leave comments, you need to log in
Why does the watch method in node.js fire more than once?
There is an index.js file:
const fs = require("fs");
var mainFile = './src/vuefy/main.js';
fs.watch(mainFile, (eventType, filename) => {
console.log(filename);
//build();
});
Answer the question
In order to leave comments, you need to log in
This is a windows API issue https://github.com/nodejs/node/issues/3042
You can use fs.watchFile instead of fs.watch, but it is very slow and as it is written in the off-doc: "Note: fs.watch() is more efficient than fs.watchFile and fs.unwatchFile. fs.watch should be used instead of fs.watchFile and fs.unwatchFile when possible."
Because life is pain.
Why do you think the method should be called once and make a full log output, including the event type.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question