galkatz373 / svelte-apexcharts

Svelte wrapper for ApexCharts
68 stars 7 forks source link

Nestjs Svelte - Cannot read properties of undefined (reading 'document') #159

Open eta32carinae opened 3 years ago

eta32carinae commented 3 years ago

Hi, I've created a Nestjs project with Svelte template. I'm trying to use this package but it gives me this error:

[Nest] 5984 - 10/26/2021, 2:34:09 PM ERROR [ExceptionsHandler] Cannot read properties of undefined (reading 'document') TypeError: Cannot read properties of undefined (reading 'document') at /home/user/project/node_modules/svelte-apexcharts/dist/index.js:12:397801 at /home/user/project/node_modules/svelte-apexcharts/dist/index.js:2:66 at Object. (/home/user/project/node_modules/svelte-apexcharts/dist/index.js:5:2) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object. (/home/user/proj

Here's my codes:

// Test-sveltapex.svelte
<script>
    import { chart } from "svelte-apexcharts";
    let options = {
      chart: {type: "bar",},
      series: [{name: "sales", data: [30, 40, 35, 50, 49, 60, 70, 91, 125],},],
      xaxis: {categories: [1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999],},
    };
  </script>
  <div use:chart={options} />
// the controller
...
  @Get()
  @Render('Test-sveltapex')
  async test():Promise<any> {
    return {};
  }

I'm new to js and I have no idea what's the problem.