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

prom-client/index has no default export #671

Closed
Javarome opened this issue Dec 23, 2020 · 13 comments
Closed

prom-client/index has no default export #671

Javarome opened this issue Dec 23, 2020 · 13 comments

Comments

@Javarome
Copy link

Javarome commented Dec 23, 2020

Hi, I just installed your package using npm and it complains:

node_modules/@willsoto/nestjs-prometheus/dist/metrics/utils.d.ts:1:8 - error TS1192: Module '"my-project/node_modules/prom-client/index"' has no default export.

1 import client from "prom-client";

Looking at the code:

import client from "prom-client";

in your utils does not have a default export.
I checked the installed version of prom-client (which is 12.0.0) and indeed it only exports specific types.

Could you fix that, or am I missing something?

Thanks!

@willsoto
Copy link
Owner

Yup! That is working as intended. You can see an example usage here

@Javarome
Copy link
Author

Javarome commented Dec 23, 2020

Sorry @willsoto I don't get it. I did exactly what is specified in that example usage. prom-client installed with version 12.0.0, as well as your package.

package.json:

dependencies: {
    "@willsoto/nestjs-prometheus": "^2.0.1",
    "prom-client": "^12.0.0"
}

AppModule.ts:

import {PrometheusModule} from "@willsoto/nestjs-prometheus"

@Module({
  imports: [
    PrometheusModule.register({
      defaultMetrics: {
        enabled: true,
        config: {
          timeout: 5000,
          includeMethod: true,
          includePath: true,
        },
      },
    })
  ],
  providers: [],
  controllers: [],
})
export class AppModule {
}

This error shows up when launching NestJS.

Could you be more specific about what I am missing? Thanks

@willsoto
Copy link
Owner

Can you confirm that v12 is the one actually being installed? It seems they released a v13 but I haven't had time to test any changes to see if there is an issue with that

@willsoto willsoto reopened this Dec 23, 2020
@Javarome
Copy link
Author

Yes I double-checked in node-modules/prom-client/package.json and it states "version": "12.0.0"
package.lock.json also states that.

@willsoto
Copy link
Owner

I'm not quite sure what the issue would be then...I'll have to take a look

@willsoto
Copy link
Owner

Do you happen to have esModuleInterop enabled or disabled?

@willsoto
Copy link
Owner

I think as a workaround you can disable skipLibCheck in your tsconfig.json.

@Javarome
Copy link
Author

My esModuleInterop is disabled:

{
  "compilerOptions": {
    "target": "ES2020",
    "module": "commonjs",
    "lib": [
      "ES2020"
    ],
    "outDir": "dist",
    "rootDir": "src",
    "inlineSourceMap": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "strict": true,
    "noImplicitAny": true,
    "esModuleInterop": false,
    "resolveJsonModule": true,
    "alwaysStrict": true
  },
  "include": ["./src/**/*.ts"],
  "exclude": [
    "node_modules",
    "test",
    "dist",
    "**/*spec.ts"
  ]
}

Did you reproduce the issue?

@willsoto
Copy link
Owner

No I didn't but I am pretty sure I know what is going on. Your tsconfig settings are incompatible with my compiled tsconfig settings - I've seen this before. Setting skipLibCheck: false should fix the issue on your end. I will need more time to think on this to find a proper fix.

@Javarome
Copy link
Author

You mean skipLibCheck: true I guess. This does workaround the problem indeed, but I agree this is not an ideal solution.
Thanks for the tip anyway.

For the record I do not have such a problem using https://github.com/digikare/nestjs-prom
Not that I would prefer using this one, just to give you more comparison insight about the origin of the problem.

@willsoto
Copy link
Owner

Yes sorry, that is what I meant.

@willsoto
Copy link
Owner

I've released v3.0.0 to hopefully fix this. I am no longer using esModuleInterop so hopefully this means TS can figure out imports.

@Javarome
Copy link
Author

Yes it does work with 3.0.0 and without the need for skipLibCheck, thanks !

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

2 participants