Skip to content

dangaogit/node-alias

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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