react-colorful: SyntaxError: Cannot use import statement outside a module
I get the following issue when trying to use react-colorful in my NextJS app:
SyntaxError: Cannot use import statement outside a module
module.exports = require("react-colorful");
import { HexColorPicker } from "react-colorful";
<HexColorPicker color={color} onChange={setColor} />
Anyone know why?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 20 (14 by maintainers)
Havent had time to test it, but i would say we can close this issue.
It feels like we did everything we could. Should we close the issue, what do you think guys?
“default” shouldn’t make the things worse. It’s a fallback. Check this thread out: https://twitter.com/nsfounder/status/1378879896135426051?s=19
“exports” is a complete hell…
Super weird. Might it be a bug of
v12.20.2? 🤔 I would recommend you to update your env to v14 since it an active LTS version:That’s about writing pure ESM packages which is definitely not what we want to be doing here and is quite inapplicable.
I am using next@10.1.3
Hi! Thanks for the report!
This package is dual (we publish both ESM and CJS files) so everything should work well everywhere, but probably we can extend package’s export somehow to provide better support of Next’s SSR.
I’ll take a look tomorrow.