There are several possible flaws that come to mind.
1) It is technically possible that these properties are accessible and changed outside the module, but only if the link to the module itself is available outside it. What makes a module accessible through its own export ( module.exports = module; which is the simplest example), will expose them.
2) You may have a name conflict with a built-in property or a future built-in property that does not exist yet (which could lead to your code breaking in future versions of node.js). This can be very problematic and very difficult to debug. Currently, the built-in properties of a module object are: children, exports, filename, id, loaded, paths, and parent .
because in the second example, you need to look for var someClient at the top of the file to make sure that the var keyword exception is intentionally in the init method.
If this is the reason, you can simply use a namespace that is not module . For example, adding var private = {}; at the beginning of each file, and then using private.someClient instead of module.someClient .
Also 'use strict'; , so the random omission of var is a mistake, not a random global one.
source share