Questions tagged [tsconfig-paths]
32 questions
19
votes
3 answers
How to have absolute import paths in a library project?
I have a library with a workspace containing two projects, one for the library itself and one for a test application.
├── projects
├── midi-app
└── midi-lib
In the workspace tsconfig.json file I configured some @app and @lib paths:
"paths":…
![](../../users/profiles/958373.webp)
Stephane
- 8,110
- 16
- 85
- 135
8
votes
2 answers
VSCode / tslint does not resolve paths in tsconfig.json
vscode is somehow not honoring my tsconfig.json (for a couple of weeks now, it has been different. eiter my bad or vscode update...)
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"paths": {
"@foo-animation/*": [
…
![](../../users/profiles/444255.webp)
Frank Nocke
- 7,493
- 3
- 58
- 89
8
votes
2 answers
tsc - doesn't compile alias paths
I have typescript and uses the aliases.
Here is part of tsconfig.json
"compilerOptions": {
"baseUrl": "./src",
...
},
By setting the base url, I can change
import User from "src/models/User.model.ts"
to
import User from…
![](../../users/profiles/7815298.webp)
ahadortiz
- 546
- 5
- 18
4
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…
![](../../users/profiles/7784165.webp)
Antony
- 305
- 2
- 10
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
| | | …
![](../../users/profiles/4956266.webp)
Motassem Jalal
- 924
- 16
- 34
3
votes
1 answer
compilerOptions.paths must not be set (alias imports are not supported)
I'm trying to map paths in tsconfig.json to get rid of relative paths hell. My React App is based on Create-React-App.
I tried this SO thread and added paths in my tsconfig.json. My tsconfig.json is as
{
"compilerOptions": {
"baseUrl": "src",
…
![](../../users/profiles/7344164.webp)
DevLoverUmar
- 4,509
- 4
- 27
- 41
3
votes
0 answers
How to resolve relative path hell (node with typescript)
I am developing a CLI using node, typescript and other packages. The idea is simple, the CLI gives you an initial structure for your node projects (javascript or typescript)
Well, while testing, I discovered a problem that I have not been able to…
![](../../users/profiles/14007707.webp)
Daniel Morales
- 31
- 3
3
votes
0 answers
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
…
![](../../users/profiles/4026227.webp)
barshopen
- 711
- 10
- 22
3
votes
1 answer
Typescript path aliases not resolved correctly at runtime
I'm running VS Code and I am currently trying to set up some aliases on my typescript project.
My dev setup rest on nodemon and ts-node, the code gets compiled to a dist folder.
So far, I succeeded to get Typescript Hero to manage the import with…
![](../../users/profiles/3708721.webp)
CrazyYoshi
- 386
- 2
- 16
3
votes
1 answer
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…
![](../../users/profiles/7216435.webp)
C.Darg
- 51
- 4
2
votes
1 answer
Short Imports with TypeScript Path Mapping in tsconfig
I'm trying to create short importes for my Angular Modules.
Below is what I've modified in tsconfig.base.json file.
{
"compileOnSave": false,
"compilerOptions": {
"importHelpers": true,
"outDir": "./dist/out-tsc",
"baseUrl": "",
…
![](../../users/profiles/14048048.webp)
Calvin
- 53
- 3
2
votes
1 answer
cannot run compiled typescript prog using module resolution
I'm trying to compule the following typscript file
import { magic } from 'lib/magic';
magic();
The filestructure is:
./src/
main.ts
lib/
a/magic.ts
b/magic.ts
Inside tsconfig.json I map lib/magic to the right file as…
![](../../users/profiles/419425.webp)
Jeanluca Scaljeri
- 19,619
- 37
- 147
- 259
2
votes
1 answer
serverless framework not recognizing tsconfig's paths
I'm trying to deploy my Node.js app to Lambda using Serverless framework, however, my Node code uses paths from tsconfig.json for referencing imports but the Serverless deploy process fails. How do you wire up serverless.yml to acknowledge and use…
![](../../users/profiles/418549.webp)
Tom Schreck
- 4,669
- 11
- 60
- 118
2
votes
1 answer
Is it possible to add environment variables to a tsconfig.json file?
I have a tsconfig.json file
containing
{
"extends": "../../zlux-app-manager/virtual-desktop/plugin-config/tsconfig.base.json",
"include": [
"src/**/*.ts",
"../../zlux-platform/interface/src/mvd-hosting.d.ts"
],
"compilerOptions": {
…
![](../../users/profiles/9571770.webp)
Swetank
- 33
- 5
1
vote
1 answer
TypeScript compiler error while finding absolute paths mentioned in `tsconfig.json`
I have the following directory structure:
.
├── \ .babelrc
├── README.md
├── package-lock.json
├── package.json
├── postcss.config.js
├── public
│ ├── icon128.png
│ ├── icon16.png
│ ├── icon48.png
│ ├── manifest.json
│ └── popup.html
├──…
![](../../users/profiles/6141587.webp)
deadcoder0904
- 3,758
- 1
- 27
- 91