Questions tagged [tsconfig-paths]

69 questions
35
votes
5 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…
ahadortiz
  • 916
  • 1
  • 9
  • 20
32
votes
2 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":…
Stephane
  • 11,836
  • 25
  • 112
  • 175
26
votes
5 answers

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…
CrazyYoshi
  • 1,003
  • 1
  • 8
  • 19
20
votes
6 answers

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", …
DevLoverUmar
  • 11,809
  • 11
  • 68
  • 98
12
votes
4 answers

Absolute path in the tsconfig doesn't work

I saw some questions about this problem, none of them does not work I have a nodejs project along with Typescript. I do not like to use a relative path.I get the following error, when I set path in tsconfig : Cannot find module…
Mina Mohammadi
  • 285
  • 1
  • 4
  • 14
10
votes
2 answers

Cannot find module 'tsconfig-paths/register'

I'm trying to run a typescript script with ts-node in CLI, which means I don't have a package.json. Here's the command I'm trying to run: npx -p typescript@latest -p ts-node@latest -p @types/node@latest ts-node -T --project…
Michael Khaliavski
  • 101
  • 1
  • 1
  • 5
9
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/*": [ …
Frank N
  • 9,625
  • 4
  • 80
  • 110
7
votes
1 answer

TS config path error. Error: Cannot find module '@/models/UserSchema'

I am making a discord bot and I was trying the path aliases feature on typescript. but I somehow keep getting this error when I am using it. I am using NodeJs and using Here is the error message Error: Cannot find module…
Frastio Agustian
  • 85
  • 1
  • 1
  • 7
7
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…
6
votes
1 answer

How do I transpile aliased paths in TypeScript to JavaScript?

I have a TypeScript project that I am trying to transpile into executable JavaScript which makes use of path aliases. This is required for the NPM package I am working on. For example here with importing a method from my lib directory without…
markodeezy
  • 71
  • 2
6
votes
0 answers

using tsconfig-paths with es modules

I have a typescript project that uses commonjs modules, I use ts-node to run it, and tsconfig-paths to resolve tsconfig.compilerOptions.paths at runtime. now I want my project to migrate to use es modules, so I made some changes: add type: module…
Sh eldeeb
  • 1,589
  • 3
  • 18
  • 41
5
votes
0 answers

publish typescript library with paths & tsconfig-paths

I wanted to put shared common code into a private npm registry. Using the below commands & tsconfig has been working great, until I've wanted to make one project depend on another through publishing to an npm registry. I have several folder and a…
Mtfbwm2
  • 51
  • 1
5
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": "", …
Calvin
  • 75
  • 1
  • 4
5
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…
Tom Schreck
  • 5,177
  • 12
  • 68
  • 122
5
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": { …
1
2 3 4 5