react-icons / react-icons

svg react icons of popular icon packs
https://react-icons.github.io/react-icons/
Other
11.25k stars 725 forks source link

[Bug]: Error with react-icons and vercel with Astro #846

Closed determinationlove closed 7 months ago

determinationlove commented 7 months ago

Describe the bug

error   Named export 'FaCircleUser' not found. The requested module 'react-icons/fa6/index.esm.js' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'react-icons/fa6/index.esm.js';
const { FaCircleUser } = pkg;

Expected behavior

Under normal circumstances, it should be able to build smoothly

Minimal sample repository URL

https://github.com/react-icons/react-icons/issues/754

Steps To Reproduce

1.

import { FaCircleUser } from "react-icons/fa6";
<FaCircleUser className="mr-4 w-10 h-10 sm:w-16 sm:h-16 rounded-full" />

2. Vercel Deploy

3. SyntaxError: Named export 'FaCircleUser' not found. The requested module 'react-icons/fa6/index.esm.js' is a CommonJS module, which may not support all module.exports as named exports.

Package version

^4.11.0

Relevant log output

error   Named export 'FaCircleUser' not found. The requested module 'react-icons/fa6/index.esm.js' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'react-icons/fa6/index.esm.js';
const { FaCircleUser } = pkg;

SyntaxError: Named export 'FaCircleUser' not found. The requested module 'react-icons/fa6/index.esm.js' is a CommonJS module, which may not support all module.exports as named exports.

Additional context

No response

determinationlove commented 7 months ago

OMG I found the solution... https://github.com/withastro/astro/issues/5657

place this

import { FaCircleUser } from "react-icons/fa6";

Change to this

import { FaCircleUser } from "react-icons/fa6/index"; // add "index"