TypeScript

Paths not resolving at runtime without bundler in TypeScript

TypeScriptAdvanced ModulesPaths & BaseUrladvanced

What this snippet does

TypeScript paths are purely a compile-time concept; at runtime in Node.js, the alias '@/' will fail unless a bundler or ts-node registration resolves it.

Expected output

Runtime Error: Cannot find module '@/models'

Why practise typing this

Typing advanced modules code builds muscle memory for the symbols and indentation TypeScript uses most, which prose-based typing tests never cover. DevType measures your words per minute and accuracy on this snippet and tracks the individual characters you mistype, so later lessons can target them.

More TypeScript practice

Browse all TypeScript snippets →