当我尝试导入这样的Chart.js模块时,我已经安装了chart.js v4.0.1,以便在我的react项目中使用:
import Chart from 'chart.js/auto'它显示了我的终端中的一个错误,即模块的解析失败了。
./node_modules/chart.js/dist/chart.js 554:18
Module parse failed: Unexpected token (554:18)
File was processed with these loaders:
* ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
| };
| class DatasetController {
> static defaults = {};
| static datasetElementType = null;
| static dataElementType = null;这是否是因为在我的节点模块中有一些不推荐的包,而最新的chart.js版本仍然是如此的危险,需要一些解决办法才能工作呢?
发布于 2022-11-25 11:19:12
这是因为您可能使用的是不支持静态属性的we pack 4,所以您将需要更新到webpack 5,或者使用babel /预设的env配置和babel加载程序来传输它。
https://stackoverflow.com/questions/74570679
复制相似问题