require-alias-node
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
It’s the alias of require-import-alias
Install
1 | 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, it’s not very intuitive !
1 | const component = require('../../../src/component'); |
Now we can use this tool require-alias-node
to set alias for the moduleA, is looks like:
1 | const requireAliasNode = require('require-alias-node'); |
and you can also use it with import
in ES2015(set an alias is a module, and use the alias in anthor module)
setAlias
1 | import requireAliasNode from 'require-alias-node' |
using it
1 | import component from 'component' |
It’s so graceful !