简体   繁体   English

找不到 ChakraUI React 导入模块:无法解析“@public/icons”

[英]ChakraUI React import Module not found: Can't resolve '@public/icons'

I have found similar questions here on stackoverflow and none of it helped to solve my issue我在stackoverflow上发现了类似的问题,但都没有帮助解决我的问题

I have a icons.js file in public where i export various icons to the pages我有一个公开的icons.js 文件,我将各种图标导出到页面

And on the page i import that particular file using在页面上我使用导入该特定文件

import { FastFeedbackIcon } from '@public/icons';

i have declared jsconfig.json file for public folder我已经为公共文件夹声明了 jsconfig.json 文件

And here is the error i am getting on the console & browser这是我在控制台和浏览器上遇到的错误

./pages/index.js:14:0
Module not found: Can't resolve '@public/icons'


12 | import { useAuth } from '@/lib/auth';
13 | import { auth } from 'firebase';
> 14 | import { FastFeedbackIcon } from '@public/icons';

And here is the public/icons.js file这是 public/icons.js 文件

import { createIcon } from '@chakra-ui/icons';
export const FastFeedbackIcon = createIcon({
  displayName: 'FastFeedbackIcon',
  viewBox: '0 0 46 32',
  path: (
    <path
      d="M19.557.113C11.34.32 9.117 8.757 9.03 12.95c1.643-2.67 4.62-3.08 6.931-3.08 2.825.085 10.27.205 17.458 0C40.61 9.663 44.802 3.28 46 .112c-5.391-.085-18.228-.205-26.443 0zM14.422 14.234C3.332 14.234-.468 24.76.045 31.948c3.594-6.418 7.617-7.53 9.243-7.445h6.675c5.956 0 11.039-6.846 12.836-10.27H14.422z"
      fill="currentColor"
    />
  )
});

And This is the jsconfig.json file这是 jsconfig.json 文件

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@/components/*": ["components/*"],
      "@/lib/*": ["lib/*"],
      "@/pages/*": ["pages/*"],
      "@/styles/*": ["styles/*"],
      "@/utils/*": ["utils/*"],
      "@/public/*": ["public/*"]
    }
  }
}
from '@public/icons';

to

from '@/public/icons';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM