Fix: Setup path alias for Typesctipt/ Nest/js
With Typescript/Nest js if we want to set path alias like dont want to traverse to whole path example —
we have a file — configs/env.config.ts
how to import that config:
import { CONFIG } from ‘configs/env.config.ts’
but we can also set path alias to short path to folder or to file by —
- open tsconfig.json and inside compilerOptions add a key paths —
2. And also update in tsconfig.json > compilerOptions
“moduleResolution”: “node”,
3. npm i tsconfig-paths
4. Now u can use path alias likke —
import CONFIGS from ‘@env’;
Is this article helpful ? Please clap and write in comment section