0.2.3 • Published 4 years ago

@dangao/node-alias v0.2.3

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

node-alias

node module alias

install

npm i @dangao/node-alias --save

or

yarn add @dangao/node-alias

Fix

  • To solve the problem that nodejs cannot use path mapping

before

// in {workspace}/src/service/xx/xxx.ts
import file from "../../../utils/xx";

after

// in {workspace}/src/env.ts
// Configuration alias
import alias from "@dangao/node-alias";
alias.add("~", __dirname);
// in {workspace}/src/main.ts
// Import it in your entry file
import "./env";
// in {workspace}/src/service/xxx.ts
// Use it anywhere in the project
import file from "~/utils/xx";
  • Resolve module dependency alias conflicts