Ant design charts install error: '__spreadArray' is not exported from 'tslib'

Ant design charts install error: '__spreadArray' is not exported from 'tslib'

我尝试安装 ant design charts 但出现以下错误:

./node_modules/@antv/algorithm/es/gaddi.js
Attempted import error: '__spreadArray' is not exported from 'tslib'.

我收到 0 个警告。我完成的步骤:

  1. npm install @ant-design/charts
  2. npm install tslib --save
  3. npm audit fix
  4. npm react update
  5. npm i typescript

我尝试了 3 次重新安装,但 none 解决了我的问题。知道出了什么问题吗?我该如何解决?

奇怪,但我解决了问题:

在我的 react.js 文件中

import { Line } from '@ant-design/charts';

不完全在

之下
import React

所以把位置改成这样后:

import React, { useEffect, useState } from 'react'
import { Line } from '@ant-design/charts';

已解决问题

显然通过安装最新的 tslib 包对我有用:

npm install tslib@latest --save