如何修复node_modules/chart.js/types/animation.d.ts(20,37)中的错误:错误TS 1005:应为,“”,在chart.js中

s4chpxco  于 2023-03-12  发布在  Chart.js
关注(0)|答案(2)|浏览(224)

我正在进行一个Angular 6项目,我想使用chart.js创建一些图表。
我使用npm install chart.js安装了chart.js,它的版本类似于3.5.1。
我的TypeScript版本就像2.9.0。
所以当我尝试ng serve时:

node_modules/chart.js/types/animation.d.ts(20,37): error TS1005: ',' expected.
node_modules/chart.js/types/animation.d.ts(20,46): error TS1005: ',' expected.
node_modules/chart.js/types/index.esm.d.ts(39,56): error TS1005: ';' expected.
node_modules/chart.js/types/index.esm.d.ts(39,58): error TS1011: An element access expression should take an argument.
node_modules/chart.js/types/index.esm.d.ts(39,85): error TS1005: '(' expected.
node_modules/chart.js/types/index.esm.d.ts(535,38): error TS1005: ',' expected.
node_modules/chart.js/types/index.esm.d.ts(535,56): error TS1005: ',' expected.
node_modules/chart.js/types/index.esm.d.ts(2424,37): error TS1005: ',' expected.
node_modules/chart.js/types/index.esm.d.ts(2424,50): error TS1005: ',' expected.
node_modules/chart.js/types/index.esm.d.ts(2734,63): error TS1005: ';' expected.
node_modules/chart.js/types/index.esm.d.ts(2734,69): error TS1011: An element access expression should take an argument.
node_modules/chart.js/types/index.esm.d.ts(2738,22): error TS1011: An element access expression should take an argument.
node_modules/chart.js/types/index.esm.d.ts(2742,63): error TS1005: '(' expected.
node_modules/chart.js/types/index.esm.d.ts(2746,57): error TS1005: '(' expected.
node_modules/chart.js/types/index.esm.d.ts(2746,68): error TS1005: ',' expected.
node_modules/chart.js/types/index.esm.d.ts(2746,75): error TS1011: An element access expression should take an argument.
node_modules/chart.js/types/index.esm.d.ts(2746,76): error TS1005: ')' expected.
node_modules/chart.js/types/index.esm.d.ts(2763,26): error TS1011: An element access expression should take an argument.
node_modules/chart.js/types/index.esm.d.ts(2767,67): error TS1005: '(' expected.
node_modules/chart.js/types/index.esm.d.ts(2771,56): error TS1005: '(' expected.
node_modules/chart.js/types/index.esm.d.ts(2771,67): error TS1005: ',' expected.
node_modules/chart.js/types/index.esm.d.ts(2771,73): error TS1011: An element access expression should take an argument.
node_modules/chart.js/types/index.esm.d.ts(2771,74): error TS1005: ')' expected.
node_modules/chart.js/types/index.esm.d.ts(2788,1): error TS1128: Declaration or statement expected.

这是什么,如何解决这个问题?
谢谢

zour9fqk

zour9fqk1#

正如其他人所说,降级到chart.js2.7.3版为我解决了这个问题。对于不太熟悉npm的人,下面是我用来更新包的命令:

npm remove chart.js --save
npm install chart.js@2.7.3 --save

我专门为我的离子5项目这样做。但它也应该为Angular 工作。

kiz8lqtg

kiz8lqtg2#

我尝试了几个解决方案,但找不到它们,所以我只是将chartjs 3. 5. 1降级到2. 7. 3。所以它工作得很好。

相关问题