The old way…
By Udo G at Stack Overflow
from: http://stackoverflow.com/questions/5797852/in-node-js-how-do-i-include-functions-from-my-other-files If, despite all the other answers, you still want to traditionally include a file in a node.js source file, you can use this: <code>var fs = require('fs'); // file is included here: eval(fs.readFileSync('tools.js')+'');</code>
Please note that in most cases this is bad practice and you should instead write a module. However, there are rare situations, where pollution of your local context/namespace is what you really want.
|
|||||||||||||||||||
|