question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Absolute paths, tsc complains it can't find the module

See original GitHub issue

Using 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:closed
  • Created 5 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Meligycommented, Aug 27, 2018

@olegsmetanin not sure if this issue is the best place to ask this question, but you might want to try to set the baseDir in tsconfig.json to ./src and see if that works.

1reaction
Slessicommented, Apr 4, 2018

@ds300 adding {"name": "src"} to src/package.json does make src/styles work, but really I prefer the combination of index.ts files and baseUrl and paths

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found