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

ts-node and tsconfig-paths/register not working as it should #1090

Closed
2 of 4 tasks
kielerdotdev opened this issue Sep 23, 2021 · 6 comments
Closed
2 of 4 tasks

ts-node and tsconfig-paths/register not working as it should #1090

kielerdotdev opened this issue Sep 23, 2021 · 6 comments

Comments

@kielerdotdev
Copy link

kielerdotdev commented Sep 23, 2021

Sorting

  • I'm submitting a ...

    • bug report
    • feature request
    • support request
  • I confirm that I

    • used the search to make sure that a similar issue hasn't already been submit

Expected Behavior

ts-node should use tsconfigs paths.

NOTE: Reason im asking for help in here, its the first libarry, where ive seen tsconfig-paths fuck up.
So sorry if its not an TSOA issue

Current Behavior

crashing with ```ts
TypeError: Class extends value undefined is not a constructor or null
[1] at Object. (/home/luderx/git/poc/src/controllers/test.ts:8:38)
[1] at Module._compile (internal/modules/cjs/loader.js:1072:14)
[1] at Module._compile (/home/luderx/git/poc/node_modules/source-map-support/source-map-support.js:568:25)
[1] at Module.m._compile (/tmp/ts-node-dev-hook-3323428189508646.js:69:33)
[1] at Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
[1] at require.extensions. (/tmp/ts-node-dev-hook-3323428189508646.js:71:20)
[1] at Object.nodeDevHook [as .ts] (/home/luderx/git/poc/node_modules/ts-node-dev/lib/hook.js:63:13)
[1] at Module.load (internal/modules/cjs/loader.js:937:32)
[1] at Function.Module._load (internal/modules/cjs/loader.js:778:12)
[1] at Module.require (internal/modules/cjs/loader.js:961:19)\

When using tsconfig-paths/register with ts-node, Controller from 'tsoa' becomes undefined.
Not really sure if this is a TSOA issue, or a tsconfig-paths issue.

## Steps to Reproduce
You can just use the Getting started example in TSOA docs.
Add tsconfig-paths, and add "-r tsconfig-paths/register" in ts-node.

## Context (Environment)

Version of the library: 3.11.2
Version of NodeJS: 14.17.6

- Confirm you were using yarn not npm: [x]
@kielerdotdev
Copy link
Author

kielerdotdev commented Sep 23, 2021

Found a solution after trying around a few things.
Its sort of a ghetto fix, but it works
Just add
"tsoa": ["node_modules/tsoa/dist"],
"tsoa/": ["node_modules/tsoa/dist/"],

inside tsconfig paths

@foglerek
Copy link

foglerek commented Oct 14, 2021

I ran into something similar, and the issue was that tsoa.json was being pulled in when import { Controller } from 'tsoa'; was evaluted, rather than the npm package. Adding a path alias for tsoa in tsconfig pointing to node_modules/tsoa fixed this.

@yannbriancon
Copy link

Hello!

Is there a way to avoid this workaround with a real fix?
Adding a mapping is really painful as it forces you to keep the same hierarchy after building.

@kylealwyn
Copy link

kylealwyn commented Sep 28, 2022

Was just running into this issue as well. Fixed it by providing a custom config path to the tsoa cli, e.g. tsoa -c tsoaConfig.json spec-and-routes.

@wuchichen
Copy link

Can we reopen this issue?

@douglasg14b
Copy link

Yes please, re-open this issue!

What is the root cause here that causes tsoa.json to be pulled in?

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

No branches or pull requests

7 participants