say bye to webpack multi-instances ~
// alias.config.cjs
const path = require('path');
const config = {
resolve: {
alias: {
lib: path.join(__dirname, 'lib'),
},
},
};
module.exports = config;
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
If you only need to add TypeScript support in a Module context, you can use the ESM loader:
node --import alias-register/esm ./main.js
node --loader alias-register/esm ./main.js
If you only need to add TypeScript & ESM support in a CommonJS context, you can use the CJS loader:
node --require alias-register/cjs ./main.js