0

I understand node.js is modular, and js scripts are supposed to be included via module.exports. But let's say I don't care about best practice and just want to make everything (data objects, functions, etc) in a pre-existing javascript file e.g. source.js available to a node script serve.js. Is there any way to achieve this?

This is a different to the question referenced above because that answer requires specifically formatted script using module.exports.

Community
  • 1
  • 1
geotheory
  • 22,624
  • 29
  • 119
  • 196
  • I'm not really informed on other methods, but I'd say you would probably end up fetching raw files with io, and using a form of eval. Honestly I'd try to find a way to convert these files in a node friendly manner, to avoid useless headaches – axelduch Feb 04 '16 at 13:10
  • I'd be surprised is someone hadn't devised a method to achieve this. It's ridiculous to have to manually edit every js source file to be compatible with `module.exports`. – geotheory Feb 04 '16 at 13:16
  • Possible duplicate of [In Node.js, how do I "include" functions from my other files?](http://stackoverflow.com/questions/5797852/in-node-js-how-do-i-include-functions-from-my-other-files) – stdob-- Feb 04 '16 at 13:40
  • If you check, I referenced that answer.. – geotheory Feb 04 '16 at 13:52

0 Answers0