chartjs / chartjs-adapter-date-fns

date-fns adapter for Chart.js
MIT License
100 stars 35 forks source link

Error: No "exports" main defined #61

Closed vidforstner closed 1 year ago

vidforstner commented 1 year ago

This error keeps popping up, Error: No "exports" main defined in C:\Users\info\3D Objects\4-Soft\investors\node_modules\chart.js\package.json

My code looks like this and it works without date fns:

import {
  Chart as ChartJS,
  CategoryScale,
  LinearScale,
  PointElement,
  LineElement,
  Title,
  Tooltip,
  Legend,
  Filler,
  TimeScale,
} from "chart.js";

ChartJS.register(
  CategoryScale,
  LinearScale,
  PointElement,
  LineElement,
  Title,
  Tooltip,
  Legend,
  Filler,
  TimeScale
);

import "chartjs-adapter-date-fns";
import { Line } from "react-chartjs-2";

if i remove the import the code works fine

vidforstner commented 1 year ago

Issue ended up being in package.json and tsconfig.json in package.json i removed "type": "module"

and changed tsconfig.json to "target": "es6",