Absolute paths, tsc complains it can't find the module
See original GitHub issueUsing this package with vs-code and when I am importing via the absolute path using the package.json file it tells me it can’t find it. It still transpiles and works but it’s kind of annoying.
I’ve seens some solutions include an index.d.ts file and declare the module there, for example:
In app.tsx
import HeaderComponent from 'src/HeaderComponent
In same folder as the package.json { "name": "src"}
named index.d.ts
declare module src { ... }
However I’m not getting much luck with it. Have you ran into such an IDE complaint before?
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Cannot find module that is defined in tsconfig `paths`
I faced the same issue. I tried many things and now i got a solution which works for me. I have an app...
Read more >Documentation - Module Resolution - TypeScript
Module resolution is the process the compiler uses to figure out what an import refers to. Consider an import statement like import {...
Read more >How to solve the problem with unresolved path aliases in ...
The actual cause of the issue is that the tsc compiler does not transpiles correctly the path aliases to absolute (real) paths.
Read more >tsconfig-paths - npm
Load node modules according to tsconfig paths, in run-time or via API. ... thus will not find the modules specified by paths in...
Read more >How I simplified my import paths in TypeScript
Doesn't work. Created a simple example with absolute imports and then compiled it via tsc . On running node dist/index.js the compiled JS...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@olegsmetanin not sure if this issue is the best place to ask this question, but you might want to try to set the
baseDir
intsconfig.json
to./src
and see if that works.@ds300 adding
{"name": "src"}
tosrc/package.json
does makesrc/styles
work, but really I prefer the combination ofindex.ts
files andbaseUrl
andpaths