Node.js: how to reload a module

I am new to NodeJS, so I probably make some mistakes.

I wrote a bunch of code in an external myapp file. I start NodeJS for windows and from the interpreter window I type:

var myapp = require('d:/myapp.js'); 

then I can use my functions and variables in an external module.

The problem is that if I update the code in myapp, then the interpreter does not re-read the file and uses the old version.

Now, is this normal in the first place? How to get around this problem?

PS: I spent hours on the Internet and searched in many forums, including this. It was more confusing than anything else.

Thanks.

+5
source share

Source: https://habr.com/ru/post/1235303/


All Articles