TypeScript-Node-Starter icon indicating copy to clipboard operation
TypeScript-Node-Starter copied to clipboard

Not able to import as absolute path

Open mayank-kansal15 opened this issue 6 years ago • 3 comments
trafficstars

I am not able to import modules with an absolute path. My baseUrl and absolute path are correctly set. When I searched a bit about the issue it seems like it is because of moduleResolution as "node" when I set as "classic" absolute import works.

mayank-kansal15 avatar Nov 13 '19 10:11 mayank-kansal15

hey, instead of falling back to older module resolution have you tried to work with your project tsconfigs details and use for example path aliases: https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping https://github.com/microsoft/TypeScript-Node-Starter/blob/master/tsconfig.json#L12-L16 ?

peterblazejewicz avatar Nov 13 '19 21:11 peterblazejewicz

@peterblazejewicz Appreciate the quick response, I will check these and get back.

mayank-kansal15 avatar Nov 14 '19 09:11 mayank-kansal15

@peterblazejewicz Went through both the above links and tried some combination by changing path and base URL but no success. Can you please help me here and tell what change should I do in tsconfig.json and/or in package.json so that absolute URL works both in VSCode and from the command like "npm run server".

mayank-kansal15 avatar Nov 21 '19 11:11 mayank-kansal15