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

[cube-client-core] TypeError: cube is not a function #8613

Open
mauriciocirelli opened this issue Aug 22, 2024 · 0 comments
Open

[cube-client-core] TypeError: cube is not a function #8613

mauriciocirelli opened this issue Aug 22, 2024 · 0 comments
Assignees
Labels
question The issue is a question. Please use Stack Overflow for questions.

Comments

@mauriciocirelli
Copy link

mauriciocirelli commented Aug 22, 2024

Problem

We have a typescript project which we import cube-client-core library.
We are trying to instantiate it as documented:

import cube, { CubeApi } from '@cubejs-client/core';

const cubeApi = cube(token, {
  apiUrl: `${process.env.CUBEJS_API_URL}/cubejs-api/v1`,
});

The project compiles fine with tsc command.
However, during runtime, when this code is called, we get the following error:

TypeError: cube is not a function

We are struggling with that as we cant figure it out.
Logging the cube() function with JSON.stringnify gives us something weird:

{"DEFAULT_GRANULARITY":"day","GRANULARITIES":[{"title":"w/o grouping"},{"name":"second","title":"Second"},{"name":"minute","title":"Minute"},{"name":"hour","title":"Hour"},{"name":"day","title":"Day"},{"name":"week","title":"Week"},{"name":"month","title":"Month"},{"name":"quarter","title":"Quarter"},{"name":"year","title":"Year"}]}

It seems it is holding the entire module and the default export is not working properly.

This is our tsconfig file:

{
  "extends": "@tsconfig/node-lts/tsconfig.json",
  "compilerOptions": {
    /* Visit https://aka.ms/tsconfig to read more about this file */

    "rootDir": "./src",
    "outDir": "./dist",
    "sourceMap": true,
    "moduleResolution": "nodenext",
  },
}

We are pretty sure we are missing something on the tsconfig, but cant find out what it is...

Any help would be much appreciated.

Thank you!

@mauriciocirelli mauriciocirelli added the question The issue is a question. Please use Stack Overflow for questions. label Aug 22, 2024
@igorlukanin igorlukanin self-assigned this Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question The issue is a question. Please use Stack Overflow for questions.
Projects
None yet
Development

No branches or pull requests

2 participants