Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paths created in tsconfig.json not work #649

Closed
vuggy17 opened this issue Nov 11, 2021 · 4 comments
Closed

Paths created in tsconfig.json not work #649

vuggy17 opened this issue Nov 11, 2021 · 4 comments
Labels

Comments

@vuggy17
Copy link

vuggy17 commented Nov 11, 2021

Describe the bug
I created path in tsconfig.json, then import module using that path, but compiler tells module not found

To Reproduce
Steps to reproduce the behavior:

  1. Go to tsconfig.json
  2. Add baseUrl and path
  3. Go to app.module
  4. Import that module

Expected behavior
Module imported using custom path

Screenshots
tsconfig,json
image

app.module.ts
image

Additional context

  • project stucture:
    image
@maximegris
Copy link
Owner

maximegris commented Nov 17, 2021

@vuggy17 Maybe you should try

    "paths": {
      "@shared/*": ["app/shared/*"],
    }

@whyboris
Copy link
Contributor

whyboris commented Apr 5, 2022

@maximegris -- just in case you might have an idea about this (only look into this if you have interest and time).

I tried in my project, and VS Code correctly recognizes the paths, but when I run npm start it fails:

whyboris/Video-Hub-App#752 <-- code change

tsconfig.json change:
https://github.com/whyboris/Video-Hub-App/pull/752/files#diff-b55cdbef4907b7045f32cc5360d48d262cca5f94062e353089f189f4460039e0R7

The npm start tries to run using tsconfig-serve.json and gives this error:

Cannot find module '@pipes' or its corresponding type declarations.

When I add the paths property to tsconfig-serve.json (I need to add ./ before each path) but I get this error:

The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'.

This is because I use a service worker:

const worker = new Worker(new URL('./tags.worker', import.meta.url), { type: 'module' });

If I add "module": "es2020" (for example) I get this error:

Cannot use import statement outside a module

I suspect I might have to suck it up and have ../../../../../interfaces/ instead of @my/ :trollface:

But in case you instantly know what's going wrong with my project, please let me know 🙇

@a-rizzuti
Copy link

Did you find a solution?

@whyboris
Copy link
Contributor

It's been over 2 years and it still doesn't work in my project 😔
Would appreciate anyone trying their hand at it 🙇‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants