Error: Unexpected token in `character-entities-legacy` when using this module
scottwhudson opened this issue · comments
I'm building a React library using create-react-library
, and I'm getting an error that tracks back to refractor
when trying to install a package (react-syntax-highlighter
) that depends on refractor
.
My error looks like this:
rollup v0.64.1
bundles src/index.js → dist/index.js, dist/index.es.js...
[!] Error: Unexpected token
node_modules/character-entities-legacy/index.json (2:9)
1: {
2: "AElig": "Æ",
^
3: "AMP": "&",
4: "Aacute": "Á",
I've tried uninstalling, deleting node_modules
and reinstalling the package twice with no success.
I've consulted all of my usual resources to resolve this without any success. Am I missing something here?
The problem is probably your webpack config. The issue is similar to syntax-tree/hast-util-sanitize#1 (comment). Could you try that, and see if that works?
Yep, adding the json plugin to my rollup config solved the issue. I totally wouldn't have guessed that.
Thank for the tip!
Yep, adding the json plugin to my rollup config solved the issue. I totally wouldn't have guessed that.
Thank for the tip!
Hi Scott. What should I put in rollup config exactlty?
Nevermind, I figured it out by npm installing @rollup/plugin-json and then adding that to my rollup config. As you mentioned. Thanks for the help.