Nodejs require returns same old file when requiring a second time after the file changed
javascript, node.js, require
Solution
If you don't want to restart the app do this every time you require it.
var path = require('path');
var filename = path.resolve('./tools.js');
delete require.cache[filename];
var tools = require('./tools');
Problem
So inside my nodejs server file I have the line: ``` tools=require("./tools.js"); ``` The tools file contains functions and thelike that I change alot, so I figured instead of restarting the server everytime I change something, I could simply add some way for me to re-require the tools.js, and so I did. However now the problem is, when I start the program, change the tools.js and make it re-require it, it requires it again as if it was still in the state it was when it was first required. What? Edit: I don't want to restart the app upon a file change, since that would be the same as restarting the server, which is what I want to prevent! So I need something that let's me re-require it, ignoring module caching or whatever. Any ideas what could help me here?