Skip to content

Could not find a declaration file for module 'plotly.js/dist/plotly.js' #155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
priyatham-k opened this issue Mar 12, 2021 · 11 comments
Closed

Comments

@priyatham-k
Copy link

priyatham-k commented Mar 12, 2021

"@angular/animations": "~11.0.9",
"@angular/common": "~11.0.9",
"@angular/compiler": "~11.0.9",
"@angular/core": "~11.0.9",
"@angular/forms": "~11.0.9",
"@angular/platform-browser": "~11.0.9",
"@angular/platform-browser-dynamic": "~11.0.9",
"@angular/router": "~11.0.9",
"angular-plotly.js": "^3.0.0",
"bootstrap": "^4.6.0",
"moment": "^2.29.1",
"ng-click-outside": "^7.0.1",
"ngx-color-picker": "^11.0.0",
"ngx-pagination": "^5.0.0",
"plotly.js": "^1.58.4",
"plotly.js-dist": "^1.58.4",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.10.2"

why I'm getting this
Could not find a declaration file for module 'plotly.js/dist/plotly.js'.

@andrefarzat
Copy link
Collaborator

Hello @priyatham-k , have you tried installing the @types/plotly.js package ?

@priyatham-k
Copy link
Author

Thanks, @andrefarzat for responding, installed @types/plotly.js in the project, but no luck ,still the same error...

@andrefarzat
Copy link
Collaborator

@priyatham-k I did a research and find out that the .d.ts files for plotly is quite complicated. Please see this comment for a .d.ts file an user has created: plotly/plotly.js#28 (comment)

@StefanAleksik
Copy link

Same issue :( any news?

@andrefarzat
Copy link
Collaborator

@StefanAleksik have you checked the comment I mentioned ( plotly/plotly.js#28 (comment) ) ?

@brmc
Copy link

brmc commented Apr 10, 2021

Is there any update on this? @andrefarzat, the comment you're referencing provides a TDS for 1.53 which is about a year old

@dongqiuyinggrace
Copy link

I have this issue as well. Does anyone has solution for this? I have been seeking fixing method for a whole day, very frustrated.

@CorentinMAG
Copy link
Contributor

CorentinMAG commented Apr 22, 2021

@dongqiuyinggrace
Actually you need to install plotly.js-dist via npm instead of plotly.js,
See this : #150 (comment)
and you can find more on stack overflow: https://stackoverflow.com/questions/54200157/should-i-install-plotly-js-or-plotly-js-dist-via-npm

npm uninstall plotly.js
npm install plotly.js-dist angular-plotly.js
npm install -D @types/plotly.js

then go to node_modules/@types and rename the plotly.js folder to plotly.js-dist

in app-module.ts

import { NgModule } from '@angular/core';

import * as PlotlyJS from 'plotly.js-dist';
import { PlotlyModule } from 'angular-plotly.js';

PlotlyModule.plotlyjs = PlotlyJS;

@NgModule({
    imports: [CommonModule, PlotlyModule],
    ...
})
export class AppModule { }

and it should works

@dongqiuyinggrace
Copy link

It indeed works, thank you very much!

@brmc
Copy link

brmc commented May 2, 2021

For anyone else coming along, the solution by @CorentinMAG works, but instead of renaming the directory, you should install it as an alias. that way you will have consistent environments wherever you need them

ng add @types/plotly.js-dist@npm:@types/plotly.js

@vladyslav-n
Copy link

@brmc big thanks for your suggestion, worked like a charm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants