How can I enable absolut…

less than 1 minute read

How can I enable absolute imports inside an app? If I put baseUrl: "." in apps/app/tsconfig.json TS can’t find libs packages

Responses:

Same for baseUrl: "./src"

I’d love this possibility as well

Did you ever figure this out ? I’d love to be able to do this within apps

No :/

Ok I just tried something . This seems to work in VSCode and while running a nextjs app at least So I added this to the top of the paths array in the root tsconfig.json

"paths": { "$*": ["apps/*"], ... } And now I can import with import X from '$APP_NAME/...';

trying to build it as well now

I use the $ sign because the @ sign is used for scoped npm packages, so I figured there was less likelihood of naming conflicts this way

but technically you could use any symbol, or even just do it per app

technically with this approach you could accidentally import something from another app which I don’t know if that actually works, but you might prevent that with some linting I think

Does the linter complains?

Nx lint have rules for this

Updated: