Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aliased

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aliased

Allow explicit aliasing of packages

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

aliased

Simple module aliasing.

EXAMPLE

package.json:

{
  "aliases": {
    "underscore": "lodash"
  }
}

example.js:

const _ = require('underscore')
…
$ node -r aliased example.js // uses lodash instead of underscore

Or…

server.js:

require('aliased').register()
const example = require('./example.js') // uses lodash instead of underscore

USAGE

This module provides simple module aliasing. Aliases go in your package.json in the aliases property. The key is the name of the alias, the value is the name of the actual package.

While you can provide aliases of relative requires, eg require('./foo') this treats the string as opaque, so it'll catch anyone requiring the relative path, even if it would oridinarly point at a different file.

Similarly, values can be relative, but they're substituted literally and so anything using them that's not in the same path as your package root will probably have a bad day.

So... probably don't use relative paths with this. module-alias and path-alias are better choices for that.

DISCLAIMER

I'm not saying this module is a good idea. Loading something different off disk than you required is probably going to lead to confusion. But if you must have aliases, it's an option.

PRIOR ART

  • module-alias to treat local files like packages.
  • getmod is an alternative module loader (eg, thing other than require) with aliases.
  • load-alias is another alternative module loader with aliases.
  • path-alias to treat local files like packages.

FAQs

Package last updated on 18 May 2017

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