Questions tagged [tsconfig-paths]
69 questions
5
votes
2 answers
How to register `tsconfig-paths` for `tsc-watch`?
I am trying to set up relative paths for my application running it with tsc-watch. But when I try to access enum in shared folder from feature folder, I get "Error: Cannot find module". Running the application with ts-node works fine. How I can use…

Antony
- 585
- 2
- 6
- 14
4
votes
1 answer
Next.js 13 project references path aliases throwing webpack error
I'm migrating a small and old react project (and its nestjs server) to Next.js 13. I'm doing that by scaffolding from a CLI called Create T3 App. I use project references a lot, in all projects I work on and I'm trying to do that here like…

his dudeness
- 316
- 3
- 14
4
votes
1 answer
How to use tsconfig-paths with ts-node
How do you setup paths with typescript to run with ts-node? And later compile paths to absolute paths when compiling?
I have following very minimal structure:
koki.ts:
export const calculate = (a: number, b: number) => {
return a +…

sensei
- 7,044
- 10
- 57
- 125
4
votes
1 answer
Typescript compiles successfully but node cannot find module
Node error Error: Cannot find module 'hello' even though Typescript compiled successfully.
Dir structure (note this is almost identical to tsconfig docs for baseUrl)
main
| src
| ├─ index.ts
| └─ hello
| └── index.ts
└── tsconfig.json
└──…

user14629378
- 61
- 1
- 6
4
votes
0 answers
require() of ES modules is not supported
I have an issue when I try to run webpack with webpack.config.ts written in typescript and ts-node has "require": ["tsconfig-paths/register"]
// tsconfig.json
{
compilerOptions:{
paths: { /* ----------------- */ }
},
'ts-node':{
…

Sh eldeeb
- 1,589
- 3
- 18
- 41
4
votes
2 answers
Can I set a typescript configuration `tsconfig.json` path on the VSCode IDE to use?
I have a project structure like the following:
.
└── my-app/
├── .configs/
│ ├── tsconfig.json
│ ├── webpack.merge.ts
│ ├── webpack.dev.config.ts
│ └── webpack.prod.config.ts
├── node_modules
├── src/
│ └──…

M.Holmes
- 403
- 1
- 7
- 22
4
votes
0 answers
Can not jump to defination when import .vue in ts file via alias,instead jump to shims-vue.d.ts
I'm using vscode.
When import via alias, ctrl + click welcome jump to shims-vue.d.ts.
// router.config.ts
import welcome from '@pages/welcome/welcome.vue'
When import via relative path, ctrl + click welcome jump to shims-vue.d.ts, but click…

shixinla
- 41
- 1
4
votes
2 answers
Add path alias for typescript
I am using create-react-app as scaffolding and tsconfig-paths as extension of my tsconfig because create-react-app is removing my paths when ran. I have been using this setup for a year now and I have no problems with it but recently when I created…

Ryan Garde
- 742
- 1
- 7
- 20
4
votes
1 answer
Creating custom absolute paths with create-react-app
I've created a React project with typescript using create-react-app version 3.4.1.
I'm trying to avoid the use of relative paths in my project. Here's a part of my project tree:
/
|_ public
|_ tests
|_ src
|____ Scenarios
|____ Components
…

barshopen
- 1,190
- 2
- 15
- 28
3
votes
1 answer
Absolute imports issue in react with typescript
I've been wandering through posts and posts about this and haven't been able to fix it. They all state pretty much the same: take notice of tsconfig.json's nesting, correctly set the baseUrl and explicitely mention filenames if were using index…

Vladimir
- 393
- 3
- 16
3
votes
0 answers
What does tsconfig.json's references.path.prepend do?
I don't understand the official documentation of what prepend does, even though I understand everything up to this point:
The second paragraph is what confuses me.
Prepending a project will include the project’s output above the output of the…

Daniel Kaplan
- 62,768
- 50
- 234
- 356
3
votes
2 answers
Typescript: IntelliJ showing error when importing even when import is resolved correcty
I'm working on an Angular project. I have a library tools and a project example. My project structure looks like this (Monorepo)
root
|-- projects
| |-- example
| | |-- src
| | | `-- app
| | | |-- app.module.ts
| | | …

Motassem Jalal
- 1,254
- 1
- 22
- 46
3
votes
2 answers
How to use tsconfig-paths with pm2?
I'm trying to deploy my typescript project with pm2, but the argument seems not working correctly.
Here is ecosystem.config.yml:
apps:
- name: 'node-app'
script: './src/main.ts'
interpreter: './node_modules/.bin/ts-node'
# they dont't…

C.Darg
- 51
- 1
- 4
2
votes
1 answer
Can't use TSConfig Paths in the Jest test files
Well, the title is pretty auto-explainable: I have set my tsconfig paths so that I can use @configs/logger instead of ../../configs/logger everytime in my APP files. But if I try to use those path mappings in the jest test files, it doesn't…

João Casarin
- 674
- 2
- 9
- 27
2
votes
1 answer
TS-Jest not resolving tsconfig paths
I have already added these paths to tsconfig.json:
{
"compilerOptions": {
"lib": ["ESNext"],
"moduleResolution": "node",
"noUnusedLocals": true,
"noUnusedParameters": true,
"removeComments": true,
…

João Casarin
- 674
- 2
- 9
- 27