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

TypeError: winston_loki_1.default is not a constructor #121

Open
vothanhbinhlt opened this issue Oct 27, 2022 · 2 comments
Open

TypeError: winston_loki_1.default is not a constructor #121

vothanhbinhlt opened this issue Oct 27, 2022 · 2 comments

Comments

@vothanhbinhlt
Copy link

Hello there, I am using this module with Nestjs. I have a problem

npm run start:dev                                                                                                                                       4s  14.20.1  17:15:07

> [email protected] start:dev /Users/binhvo/Workspaces/devpanel/uiv4backend-v2
> nest start --watch
[5:15:38 PM] Starting compilation in watch mode...

[5:15:57 PM] Found 0 errors. Watching for file changes.


/Users/binhvo/Workspaces/devpanel/uiv4backend-v2/src/app.module.ts:58
        new LokiTransport({
        ^
TypeError: winston_loki_1.default is not a constructor
    at Object.<anonymous> (/Users/binhvo/Workspaces/devpanel/uiv4backend-v2/src/app.module.ts:58:9)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:101:18)
    at Object.<anonymous> (/Users/binhvo/Workspaces/devpanel/uiv4backend-v2/src/main.ts:4:1)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
@VipinGoyal
Copy link

VipinGoyal commented Nov 1, 2022

Are you importing it via import instead of require, probably thats the reason for this error.
In order to avoid this, this worked for me i.e.

Add following in tsconfig.json and
"esModuleInterop": true

and this should work now.
import LokiTransport from 'winston-loki';

@JaniAnttonen
Copy link
Owner

@VipinGoyal's answer is probably the way to go. Leaving the issue open for clarity's sake.

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

No branches or pull requests

3 participants