question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Import error: "Module 'chartjs-plugin-datalabels/types/index' has no default export."

See original GitHub issue

Trying out Chart.js, and have been told I need to use the chartjs-plugin-datalabels to be able to write the percentage text on the piew pieces.

I installed and imported the chartjs-plugin-datalabels as per the documentation into my Angular 7 project (actually Ionic 4, which uses Angular 7), but vscode reports the following error on the import…

Module '"../../../../node_modules/chartjs-plugin-datalabels/types"' has no exported member 'ChartDataLabels'.ts(2

I have the following versions "chart.js": "^2.8.0", "chartjs-plugin-datalabels": "^0.6.0",

If I go to the node_modules\chartjs-plugin-datalabels\types\index.d.ts file, I also see a similar error here for the line

declare module 'chart.js

Invalid module name in augmentation. Module 'chart.js' resolves to an untyped module at 'd:/dev/ionic/chartjstest/node_modules/chart.js/dist/Chart.js', which cannot be augmented.ts

If I proceed, and try to run, I then get the compile error

[ng] ERROR in node_modules/chartjs-plugin-datalabels/types/index.d.ts(5,16): error TS2665: Invalid module name in augmentation. Module 'chart.js' resolves to an untyped module at 'D:/dev/ionic/chartjstest/node_modules/chart.js/dist/Chart.js', which cannot be augmented. [ng] src/app/home/pie-graph/pie-graph.component.ts(3,10): error TS2305: Module '"D:/dev/ionic/chartjstest/node_modules/chartjs-plugin-datalabels/types/index"' has no exported member 'ChartDataLabels'.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:27 (7 by maintainers)

github_iconTop GitHub Comments

5reactions
danielwstrimpelcommented, Apr 11, 2019

@simonbrunel the correct way to import the library and get a reference to the output in Typescript is import * as ChartDataLabels from 'chartjs-plugin-datalabels'; (based on how the library is currently being exported)

4reactions
danielwstrimpelcommented, Apr 11, 2019

You can fix this issue with installing the types for Chart.js via npm install @types/chart.js

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module has no default export Error in TypeScript | bobbyhadz
The "Module has no default export" error occurs when we try to import as default from a module that doesn't have a default...
Read more >
error TS1192: Module '" A.module"' has no default export
This was a simple error. It occurred due to the missing {} around the module name in the import statement itself.
Read more >
Module '"x"' has no default export. even with esModuleInterop ...
Actual behavior. src/a.ts:1:8 - error TS1192: Module '"/x/a"' has no default export. 1 import a from './a'; ~ ...
Read more >
error TS1192: Module has no default export [Solved] - SPGuides
This line was creating the issue. Then I have modified the code like below: import * as React from 'react'; export default class...
Read more >
Typescript: don't use default import when converting require to ...
Alt + enter on this line and choose "Convert require to import". You will get import a from './a'; Which is wrong when...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found