We can access local module using require function but cannot access global module through it. I read somewhere that to use global module we need to make it local then import it through require function. So if we cannot access global module directly, then what is the need of using it.
What is the difference between local and global module in Node.js? When to use local and global module?
8.9k Views Asked by Badal At
3
There are 3 best solutions below
2
On
A general use of global node module to my experience will be:
If all my applications that uses that same node module (of the same version or I do not care which version , latest is fine for me), then I will install that node-module globally. One good example.example will be node module that I use it for testing -- e.g. mocha.
You should: