Import no longer working after upgrading [chart.js] - javascript

I just upgraded from 3.9.1 to 4.0.1 and the import I had previously working no longer works:
import Chart from 'chart.js/dist/chart.min.js';
It looks like the chart.min.js file no longer exists in the node_module. I couldn't find any information about this breaking change on GitHub or in the docs.
Any more information would be helpful, thanks!
I tried changing the import to use a different file but the same error message persists:
Missing "./dist/chart.umd.js" export in "chart.js" package

The reason I was using this method is because I am using the web framework svelte-kit and in the previous version of chart.js import Chart from 'chart.js/auto'; was not working for me due to the build step. I tried it again after upgrading to v4 and it appears to be working now. Thanks!

Related

The requested module '/node_modules/.vite/deps/chart_js.js?v=425f86ec' does not provide an export named 'default'

I'm using Sveltekit and I upgraded chart.js from #2.9.4 to its latest version, upon upgrading I get the below error:
500
The requested module '/node_modules/.vite/deps/chart_js.js?v=425f86ec' does not provide an export named 'default'
SyntaxError: The requested module '/node_modules/.vite/deps/chart_js.js?v=425f86ec' does not provide an export named 'default'
I get above stated error as I import it as below:
import chartjs from 'chart.js';
I also get the same error in any version above chart.js#2.9.4.
Thank You.
Chart.js V3 is treeshakable so you need to import and register everything or if you want everything you need to import the chart from the auto import like so:
import Chart from 'chart.js/auto';
For more information about the different ways of importing and using chart.js you can read the integration page in the docs.
Since you are upgrading from Chart.js V2 you might also want to read the migration guide since there are some major breaking changes between V2 and V3

D3.js import issue with parcel

I am trying to import d3.js as follows
import * as d3 from "d3";
I have also tried the following way
const d3 = require('d3');
And I am getting the following error once the js script runs
I am using parcel to build my project, and everything has worked fine until now. From some initial digging, this seems to be related to babel from looking at related posts.
Uncaught ReferenceError: regeneratorRuntime is not defined in react 17, webpack 5 while making api calls through actions
However, adding the suggested fixes to my package.json file under the babel options has not yielded any fixes so far...
Any thoughts?

Trying to add mark.js into the svelte

I am beginner with javascript's world and svelte. And I am trying to import an external library into the svelte app that can highlight words.
However, I am running out the ideas. For example, I am trying to utilize:
import { Mark } from './mark.js';
But it shows the following error:
'Mark' is not exported by src\routes\mark.js, imported by src\routes\page.svelte
In my react app import Mark from 'mark.js'; works fine after installing with yarn

Conditional import of React Native library

I want to import a React Native library for Android only, as there is no iOS version.
I have the current setup (I used require to get around import restrictions):
if (Platform.OS === 'android') {
BackgroundColor = require('react-native-background-color');
}
But this still fails out on iOS.
Is there a standard way to do this? I can't find any documentation on it.
This issue has been already fixed by one of the PR (https://github.com/ramilushev/react-native-background-color/pull/8) which has been merged. but, owner of the library has not published the new version.
So, until new version is released, as a workaround you can manually add blank index.ios.js file in node_modules/react-native-background-color/ directory to resolve your import issue in ios. Alternatively you can fork the library.

how to Include createjs library into reactjs project

Hi I am creating an app on reactjs, which is canvas based, It require Createjs library, I am new for Reactjs I am not getting perfect idea how do this so I tried 2 ways one is using NPM install and other one is I kept my js into one folder and tries to import from there but nothing works for me, here my code
way 1 with npm install,
import createjs from 'createjs';
way 2 import downloaded js file,
import createjs from '../assets/js/createjsmin';
randomly I tried
import * as createjs from '../assets/js/createjsmin';
but nothing works for me
I add relative path to index.html and got Createjs library code into componentWillMount() using window.createjs, dn't know but I feel it can work to add all ramdom libraries in react.
So I made it work by installing this specific dependency
"#createjs/easeljs": "^2.0.0-beta.4",
And In my Component file I am importing them like this
import { Stage, Shape, TraceShape } from '#createjs/easeljs';

Categories

Resources