An open API service indexing awesome lists of open source software.

https://github.com/sooniter/alias-register

set `resolve.alias` for node.js runtime
https://github.com/sooniter/alias-register

nodejs register resolve

Last synced: 7 months ago
JSON representation

set `resolve.alias` for node.js runtime

Awesome Lists containing this project

README

          

# alias-register

Version

## Get Started

say bye to webpack multi-instances ~

```js
// alias.config.cjs
const path = require('path');

const config = {
resolve: {
alias: {
lib: path.join(__dirname, 'lib'),
},
},
};

module.exports = config;
```

```sh
node --loader alias-register ./main.js
# or
NODE_OPTIONS="--loader alias-register" node ./main.js

# if Node.js v20.6.0 and above
node --import alias-register ./main.js
NODE_OPTIONS="--import alias-register" node ./main.js
```

### Other Usages

#### ESM only loader

If you only need to add TypeScript support in a Module context, you can use the ESM loader:

##### Node.js v20.6.0 and above

```sh
node --import alias-register/esm ./main.js
```

##### Node.js v20.5.1 and below

```sh
node --loader alias-register/esm ./main.js
```

#### CommonJS only loader

If you only need to add TypeScript & ESM support in a CommonJS context, you can use the CJS loader:

```sh
node --require alias-register/cjs ./main.js
```