I'm trying to get path resolution to work in typescript.
My folder structure so far looks like this:
- src:
- index.ts
- types:
- global.d.ts
- cache.d.ts
- util:
- index.ts
- Cache.ts
Since It's getting pretty nested I would like to be able to access for example the util folder by typing
import { Whatever } from '@util'
. I've tried setting baseUrl
to ./src
and paths
to "@util": ["util/index"]
with moduleResolution
set to node
.
This is how my files look so far:
src/index.ts
import {Cache} from '@util'
const c = new Cache();
src/util/index.ts
export { default as Cache } from './Cache';
src/util/Cache.ts
export default class {
// class code goes here
}
Now, the compiler doesn't complain while I'm coding in VS Code but when I run tsc
in the command line I get an error saying that it can't find the module '@util'.
Does anyone have any ideas as to why I can't compile?