depyronick / clickhouse-client

ClickHouse Client for NodeJS
https://clickhouse.js.org
MIT License
50 stars 11 forks source link

Class extends value undefined is not a constructor or null #11

Closed spaghettifunk closed 2 years ago

spaghettifunk commented 2 years ago

Thank you for this client and for the hard work! In the latest version I'm not able to start the client. My project is in typescript and once I start the project I receive the following error

Uncaught TypeError: Class extends value undefined is not a constructor or null
    at node_modules/stream-json/filters/FilterBase.js (FilterBase.js:5:1)
    at __require (chunk-36VY3QWH.js?v=189b71f4:25:50)
    at node_modules/stream-json/filters/Pick.js (Pick.js:3:20)
    at __require (chunk-36VY3QWH.js?v=189b71f4:25:50)
    at node_modules/@depyronick/clickhouse-client/client/ClickHouseClient.js (ClickHouseClient.ts:5:1)
    at __require (chunk-36VY3QWH.js?v=189b71f4:25:50)
    at node_modules/@depyronick/clickhouse-client/index.js (index.ts:1:1)
    at __require (chunk-36VY3QWH.js?v=189b71f4:25:50)
    at dep:@depyronick_clickhouse-client:1:16

I'm not an expert but it seems the class FilterBase.js is not properly initialized or something. I tried also version 1.0.11` and I get the same error. Any pointer on what this could be?

Thank you again 😄

depyronick commented 2 years ago

Hey @spaghettifunk,

rm -rf node_modules
npm install

The error message you're receiving is mostly because some kind of circular dependency situation and it's actually happening in one of our dependencies, not the library itself. It seems like you'll need to upgrade or downgrade your node version.

spaghettifunk commented 2 years ago

Thank you for the quick reply! I tried a bunch of things like:

I created a Vue app with Vite and added the library. I still get the same message 😞 I post here the relevant files, maybe you catch something I cannot see

// package.json
{
  "name": "app",
  "private": true,
  "version": "0.0.0",
  "scripts": {
    "dev": "vite",
    "build": "vue-tsc --noEmit && vite build",
    "preview": "vite preview"
  },
  "dependencies": {
    "@depyronick/clickhouse-client": "^1.0.12",
    "vue": "^3.2.25"
  },
  "devDependencies": {
    "@vitejs/plugin-vue": "^2.3.0",
    "typescript": "^4.5.4",
    "vite": "^2.9.0",
    "vue-tsc": "^0.29.8"
  }
}
// App.vue
<script setup lang="ts">
import HelloWorld from './components/HelloWorld.vue'
</script>

<template>
  <HelloWorld />
</template>

<style>
</style>
// HelloWorld.vue
<script setup lang="ts">
import { ClickHouseClient } from '@depyronick/clickhouse-client';

const client = new ClickHouseClient({});
console.log(client);
</script>

<template>
</template>

I think the problem could be related to a dependency inside vite but I scanned each folder in node_modules and the stream-json package is not present besides the clickhouse-client.

depyronick commented 2 years ago

So basically you're trying to use this library on your frontend.

This library is just for nodejs applications, it's not intended to use on frontend environments.

You should use this library with your javascript or typescript backend project.

spaghettifunk commented 2 years ago

Yeah exactly! All right, I will create a backend and use it there instead. Thank you for the help! Really appreciate it. I will close the issue.