SyntaxError: Unexpected token with simple React/JSX component
See original GitHub issueI’m a bit embarrassed having to open this issue here, but I’ve been stuck for a few hours. I have a trivial React component
import React from "react"
import { Trans } from "react-i18next"
export default function() {
return (
<div>
<Trans i18nKey="key" />
</div>
)
}
and the latest versions of i18next and i18next-scanner. But all I get is
i18next-scanner: Unable to parse Trans component from "XXX/src/routes/Home/Component.js"
SyntaxError: Unexpected token (7:20)
Any ideas what I might be doing wrong?
Version
- i18next: 15.0.7
- i18next-scanner: 2.10.0
Configuration
{
input: [
"src/routes/Home/Component.js",
],
output: "./",
options: {
debug: true,
func: {
list: ["t"],
extensions: [".js"],
},
trans: {
component: "Trans",
i18nKey: "i18nKey",
extensions: [".js"],
},
lngs: ["en", "de"],
ns: ["translations"],
defaultLng: "de",
defaultNs: "translations",
defaultValue: "__STRING_NOT_TRANSLATED__",
resource: {
loadPath: "src/i18n/{{lng}}/{{ns}}.json",
savePath: "src/i18n/{{lng}}/{{ns}}.json",
jsonIndent: 2,
lineEnding: "\n",
},
keySeparator: ".",
},
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
ReactJS: "Uncaught SyntaxError: Unexpected token <"
However, when I tried to put my JS in a separate file, I started getting this error: "Uncaught SyntaxError: Unexpected token <". I...
Read more >Uncaught SyntaxError: Unexpected token "<" : r/reactjs - Reddit
The system tries to read a js file but it actually a HTML file the "<" token is the "<" from <!doctype html>....
Read more >ReactJS: "Uncaught SyntaxError: Unexpected token " - YouTube
JavaScript : ReactJS : "Uncaught SyntaxError : Unexpected token " [ Gift : Animated Search Engine : https://bit.ly/AnimSearch ] JavaScript ...
Read more >React function unexpected token expected
Btw, React: Unexpected token, expected “,” inside JSX [duplicate] ... passing an empty props and simple state interface to the component. map(child When...
Read more >Uncaught SyntaxError: Unexpected token < in React - Hashnode
In the below line, you need to add type="text/babel" instead of text/javascript because it contains JSX which babel needs to transpile. Copy. < ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That did it! 😃 Thank you very much!
@kenzouno1 I had the same issue. I completely removed my ‘lock’ file, deleted node-modules, reinstalled (including latest acorn as a dependency), and still got the errors. I finally got around it by adding a “resolutions” entry to my package.json, pointing to the internal acorn version.