-
Notifications
You must be signed in to change notification settings - Fork 12.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
package doesn't appear to be written in CJS, but also doesn't appear to be a valid ES module (i.e. it doesn't have "type": "module" or an .mjs extension for the entry point). Please contact the package author to fix. #18514
Comments
same here. |
this is when using vitejs |
I had the same problem after installing it on a fresh svelte-kit/electron template (https://github.com/Dax89/electron-sveltekit). |
I have multiple projects getting this same warning. |
Me too. I also have problems with the import { icon } from "@fortawesome/fontawesome-svg-core";
^^^^
SyntaxError: Named export 'icon' not found. The requested module '@fortawesome/fontawesome-svg-core' 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 '@fortawesome/fontawesome-svg-core';
const { icon } = pkg; I put it in an isolated repo here: |
A workaround until the packages are shipped as esm is to fix it in the vite config. In SvelteKit, edit |
@fabianmossberg Glad you got it working; I made #18720 a month ago and it hasn’t been triaged, so I’m not expecting a prompt fix. |
I would guess that the files in the |
Same in vite with vue. It seems that ssr/ssg is the problem. The font awesome packages gets detected as commonjs modules. From the fontawesome project you can try to adjust the esm exports to be compatible with vite's automatic detection. Or maybe vite will improve its autodetection in the future. // vite.config.ts
export default defineViteConfig({
// ...
ssr: {
noExternal: ['@fortawesome/*'],
},
}); |
I'd argue this is a duplicate of #16439, right? |
It appears the vite configuration no longer has the ssr: noExternal option. This is using vite 2.9.14. I see this comment in the index.d.ts file: /* Excluded from this release type: ssr */ |
I tried using the "All The Things" installation method and imported the js using the esm import syntax ( The error: Using the "Certain Specific Things" installation works as expected. |
I may be wrong, but using svelte and other JS frameworks with the Font Awesome JS+SVG implementation should require a different approach There is a quite new svelte component that should be used for this use case. You may find more information at https://github.com/FortAwesome/svelte-fontawesome and examples |
think you can import normally (no workaround needed) now since #19041 |
As of FA 6.2.0 and Vite, I still have the warning. |
I am also on 6.2.0 and seeing the same warning. Please reopen this issue |
Any chance to provide a reproducible test case? Please provide as many information as possible (version of FA, how it is imported, version of Vite). Even better if it is possible to provide a reduced test case hosted on github |
@tagliala you can clone this repo Dibbyo456/fa-bug-report to reproduce. |
Describe the bug
@fortawesome/fontawesome-free doesn't appear to be written in CJS, but also doesn't appear to be a valid ES module (i.e. it doesn't have "type": "module" or an .mjs extension for the entry point). Please contact the package author to fix.
I'm using FontAwesome in my sveltekit app, and using vite v2.7.3. There I get this error message
To Reproduce
npm run build
Expected behavior
The error should not show up and it should be a valid es module
Version and implementation
Version:
"@fortawesome/fontawesome-free": "^5.15.4",
"@sveltejs/kit": "1.0.0-next.202"
vite v2.7.3
Bug report checklist
The text was updated successfully, but these errors were encountered: