• Let say you have a file structure like this one:
index.ts
libs/
    services/
        superService.ts
    utils/
        parser.ts
  • you go NODE_PATH=libs ts-node index (not a ts thing but we both use ts)

All import are now relative to the path specified in the NODE_PATH variable.

and then instead of importing like this:

import phone from "../utils/parser";

// more code
  • yu can import like that:
import phone from "utils/parser";

//more code
import doStuff from "services/superService";
import phone from "utils/parser";

// more code


Published

27 June 2017

Category

node

Tags