Module Alias

Great package to cleanup/organize the includes/imports. Also is very handy to develop custom packages. Please see below. We are using the ../nexsspackages folder to keep our modules outside the folder and not installing them all the time.

npm i module-alias

In the package.json setup aliases:

// package.json
{
  "name": "mypackage",
  //...
  "_moduleAliases": {
    "@root": ".",
    "@nexssp": "../nexsspackages"
  }
}

In the program

require("module-alias/register");
const os = require("@nexssp/os"); // in the ../nexsspackages folder we have git repos of our modules

or through program

const moduleAlias = require("module-alias");
moduleAlias.addAlias("@nexssp", __dirname + "../nexsspackages");
If you found it valuable, please join to the nexss.com supporters at: Support Nexss.com