# require-alias-node

> A tool which could set an alias for the module's path which is required in the require of nodejs or import of ES6

Latest version **1.0.8** (published 2019-01-30) · ISC license · 0 weekly downloads

## Install

```sh
npm install require-alias-node
pnpm add require-alias-node
yarn add require-alias-node
bun add require-alias-node
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.8 |
| Published | 2019-01-30 |
| First published | 2018-12-26 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Alex bonjs |
| Maintainers | bonjs |
| Keywords | require, import, alias, webpack, es6 |

## Links

- npm: https://www.npmjs.com/package/require-alias-node
- npm.io page: https://npm.io/package/require-alias-node

## Dependencies (3)

- [rimraf](https://npm.io/package/rimraf.md) ^2.6.2
- [caller-dir](https://npm.io/package/caller-dir.md) ^1.0.4
- [stringify-parse](https://npm.io/package/stringify-parse.md) ^1.0.6

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 1.0.8 (latest) — 2019-01-30
- 1.0.7 — 2018-12-31
- 1.0.6 — 2018-12-30
- 1.0.5 — 2018-12-29
- 1.0.4 — 2018-12-29
- 1.0.3 — 2018-12-28
- 1.0.2 — 2018-12-28
- 1.0.1 — 2018-12-28
- 1.0.0 — 2018-12-26

## README

# require-alias-node [![Build Status](https://travis-ci.org/bonjs/require-alias-node.svg?branch=master)](https://travis-ci.org/bonjs/require-alias-node) [![](https://img.shields.io/npm/v/require-alias-node.svg)](https://www.npmjs.com/package/require-alias-node) [![](https://img.shields.io/npm/l/require-alias-node.svg)](https://img.shields.io/npm/l/require-alias-node.svg)
### A tool which could set an alias for the module's path which is required in the `require` of nodejs     or `import` of ES6

It's the alias of `require-import-alias`

#### Install
~~~bash
npm install require-alias-node
~~~

Sometimes, we may use a module with a long path to be required, and the path may contain many level, is's not very intuitive ! 
~~~javascript
const component = require('../../../src/component');
const moduleA = require('../../../src/component/render/moduleA');
~~~

Now we can use this tool `require-alias-node` to set alias for the moduleA, is looks like:
~~~javascript
const requireAliasNode = require('require-alias-node');
requireAliasNode.setAlias({
	'component': '../../../src/component',
	'moduleA': '../../../src/component/render/moduleA'
});
const moduleA = require('moduleA');
const moduleB = require('component/main/moduleB')'
~~~

### and you can also use it with `import` in ES2015(set an alias is a module, and use the alias in anthor module)

setAlias
~~~javascript
import requireAliasNode from 'require-alias-node'
requireAliasNode.setAlias({
	'component': '../../../src/component',
	'moduleA': '../../../src/component/render/moduleA'
});
~~~

using it 
~~~javascript
import component from 'component'
import moduleA from 'moduleA'
import moduleB from 'component/render/moduleB'
~~~

It's so gracefully !

---
_Source: https://npm.io/package/require-alias-node · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
