{"repo":"ilearnio/module-alias","free":true,"listed":false,"github":"https://github.com/ilearnio/module-alias","clone":"git clone https://github.com/ilearnio/module-alias.git","description":"Register aliases of directories and custom module paths in Node","language":"JavaScript","stars":1788,"topics":["node","aliases","module","nodejs"],"license":"MIT","category":"dev-tools","readme_excerpt":"module-alias [![NPM Version][npm-image]][npm-url] Donations are much appreciated and would help me continue working on this package! Donate here ❤️. --- Create aliases of directories and register custom module paths in NodeJS like a boss! No more long paths in Node, like: Enough of this madness! Just create an alias and do it the right way: It also allows you to register directories that will act just like node modules but with your own private modules, so that you can access them directly: WARNING: If you are going to use this package within another NPM package, please read Using within another NPM package first to be aware of potential caveats. Install Usage ES Modules (Node 18.19+) Add your custom configuration to your package.json (in your application's root): Run your app with the --import flag: Why the --import flag? Unlike CommonJS, you cannot import module-alias/register at runtime. All import statements are hoisted and resolved before any code runs. The --import flag loads the loader hooks before your application starts. Programmatic ESM Usage (Node 22.15+): For programmatic alias registration, create a custom loader file: Then use it with the --import flag: CommonJS (older Node 12+ versions) Add your custom configuration to your package.json : Then add this line at the very main file of your app, before any code: Now you can use aliases: Programmatic CommonJS usage If you don't want to modify your package.json or you just prefer to set it all up programmatically, th","default_branch":null,"files":null,"tree":[],"storefront":"/r/ilearnio","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/ilearnio/module-alias/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}