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.

Typescript path alias not working

See original GitHub issue

In my tsconfig.json I set a path alias but when I execute quasar dev I get the following output:

These dependencies were not found:
* @/components/admin/admin in ./src/router/routes.ts
* @/components/admin/box-plan/box-plan.component.vue in ./src/router/routes.ts
....

This is my complete tsconfig.json:

{
  "compilerOptions": {
    "target": "es5",
    "module": "esnext",
    "strict": true,
    "jsx": "preserve",
    "importHelpers": true,
    "moduleResolution": "node",
    "experimentalDecorators": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "sourceMap": true,
    "baseUrl": ".",
    "types": [
      "quasar"
    ],
    "paths": {
      "@/*": [
        "src/*"
      ]
    },
    "lib": [
      "esnext",
      "dom",
      "dom.iterable",
      "scripthost"
    ],
    "typeRoots": [
      "src/types",
      "node_modules/@types"
    ],
  },
  "include": [
    "src/**/*.ts",
    "src/**/*.vue"
  ],
  "exclude": [
    "node_modules"
  ]
}

OS: macOS Catalina (10.15.2) Node: v10.16.3 NPM: 6.9.0

Before I moved to Quasar, this app was built by a Vue CLI app and the Typescript Configuration worked as expected.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
qstieglercommented, Jan 8, 2020

@IlCallo Thanks a lot for your help. This worked:

chainWebpack (config) {
  config.resolve
    .alias
    .set('@', path.resolve(__dirname, 'src'));
}
0reactions
Davilinkcommented, Aug 9, 2021

@jeoy (and futur reference), you also need to add them to the electron section image

the “build” section is only for the “src/” folder, the other 2 in the picture is for electron-main .ts and electron-preload.ts

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why are these tsconfig paths not working? - Stack Overflow
In case anyone is using VSCode and having trouble getting the /* solution to work. Try Cmd+Shift+P > Typescript: Restart TS Server. –...
Read more >
Typescript — How to solve the problem with unresolved path ...
Generally, what should be done can be summarized as follows: Take a look into tsconfig.json and check if there are path aliases defined...
Read more >
Typescript – How to solve the problem with unresolved path ...
Generally, what should be done can be summarized as follows: Take a look into tsconfig.json and check if there are path aliases defined...
Read more >
path configuration aliases not working with nested folders.
Hello the typescript compiler seems unable to resolve path aliases when targeting subfolders. I'm using typescript v3.0.1 and my current ...
Read more >
How to configure and resolve path alias with a Typescript Project
The project will start without issues here! running javascript code with path alias. How to resolve a Typescript path alias with ts-node. With ......
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