How can I easily refer to other directories in my module without explicitly relative paths ( ../../../lib.. )?
I am writing a node module, and there are some global things that I want to reuse in my module.
Basically - I want to set the root path of the module as "global", so I can easily call other sources without using many relative paths ../../ and the like. This can cause messy code and can be easily mistaken or skipped if the design of the project changes.
So, I saw a lot of options in this post and some other libraries for working with such things (such as modules that enter the root path - app-module-path , rootpath , rfr , etc.), but they all refer to the base project / application, not the module used by others.
Setting up a global is a bad idea, and I realized that an environment variable is not such a good idea either.
Is there any good practice for this thing? Perhaps there is something I did not find or did not hear.
Here is an example of what I am trying to avoid and what I am looking for:
source share