[cube-client-core] TypeError: cube is not a function
- 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
Assessment
This issue has not been assessed yet.