我正在 React 组件中导入一些 Tabler 图标:
FeatureCards.tsx
import { IconGauge, IconUser, IconCookie } from '@tabler/icons';
不幸的是,我收到以下错误:
ERROR in ./src/components/FeatureCards.tsx 6:0-64
Module not found: Error: Package path . is not exported from package /xx/App/node_modules/@tabler/icons (see exports field in /xx/App/node_modules/@tabler/icons/package.json)
在 /xx/App/node_modules/@tabler/icons/package.json 中,导出如下所示:
"exports": {
"./*": [
"./icons/*"
]
},
我试过把它改成..:
"exports": {
"./*": [
"./icons/*"
],
".": "./icons"
},
..根据在线建议,但这会产生新的错误:
Module not found: Error: Can't resolve '@tabler/icons' in '/xx/App/src/components'
我也试过删除并重新安装我的节点模块,但没有成功。假设这是版本问题,我现在会降级。
提前感谢您的任何建议。
编辑:将 tabler 降级到 1.115.0 已经暂时解决了这个问题。
npm i @tabler/[email protected]
你应该使用
@tabler/icons-react
包
1.119.0版本也很稳定。这是为了以防万一您更喜欢降级。