Socket
Socket
Sign inDemoInstall

@types/module-alias

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/module-alias

TypeScript definitions for module-alias


Version published
Maintainers
1
Created

What is @types/module-alias?

@types/module-alias is a TypeScript type definition package for the module-alias library, which allows you to create custom module paths and aliases in Node.js applications. This can help simplify and organize your import statements, making your codebase cleaner and more maintainable.

What are @types/module-alias's main functionalities?

Registering Aliases

This feature allows you to register custom aliases for your modules. In this example, '@root' is aliased to the root directory and '@models' is aliased to the models directory.

const moduleAlias = require('module-alias');
moduleAlias.addAlias('@root', __dirname);
moduleAlias.addAlias('@models', __dirname + '/models');

Using Aliases in Imports

Once aliases are registered, you can use them in your import statements. This makes your import paths shorter and more readable.

const myModel = require('@models/myModel');

Configuration via package.json

You can also configure your aliases directly in your package.json file. This provides a centralized place for managing your module aliases.

{
  "_moduleAliases": {
    "@root": ".",
    "@models": "models"
  }
}

Other packages similar to @types/module-alias

FAQs

Package last updated on 09 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc