cube-js / cube-js/cube

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

Open
#8,613 1 comment 1 reaction 1 assignee Claimed by @igorlukanin View on GitHub
question
Dominant language
Rust
Stars
20.8k
Forks
2.1k
Avg merge
1d 2h
Merged PRs (30d)
181

Description

**Problem**

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

```javascript
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:

```json
{"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!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.