4 ms·
You are correct that in Node.JS a module is just a function that can be re-used in more than one app. But as making a module is the only way to separate your co
by z3t4 5y ago
You are correct that in Node.JS a module is just a function that can be re-used in more than one app. But as making a module is the only way to separate your code into several files and folders in Node.JS - Node.js developers also make "modules" that can not be re-used in other apps - so while one app depends on them, other apps can't depend on them and they are not published on the NPM registry... One cool thing about Node.JS modules is that you can import/require them inside main! So whether or not a function is in main or not only says how the developer likes to structure/place the functions. It's rare, but the best programmers I know likes to have all "dependencies" inside the same file - so basically they do not use any dependencies ...