Syntax error: Unexpected token in src/index.ts
See original GitHub issueDuring compilation i get this error
error: bundling failed: SyntaxError: .../node_modules/react-native-device-info/src/index.ts: Unexpected token (12:12)
I guess this is maybe because I am not using TypeScript in my project. Should I?
I tried to remove the field react-native
from the package.json
of your module - and this error gone.
Could you please recommend how to fix this?
Issue Analytics
- State:
- Created 3 years ago
- Comments:27
Top Results From Across the Web
Why does my code return "Unexpected token ="?
This error is because you are targeting a JavaScript version that isn't supported by your installed Node.js version.
Read more >Unexpected token import Error in TypeScript | bobbyhadz
To solve the Uncaught SyntaxError: Unexpected token import in TypeScript, ... trying to run a TypeScript file directly with node , e.g. node...
Read more >SyntaxError: Unexpected token - JavaScript - MDN Web Docs
The JavaScript exceptions "unexpected token" occur when a specific language construct was expected, but something else was provided.
Read more >syntaxerror unexpected token 'export' typescript - You.com
This means, that a file is not transformed through TypeScript compiler, e.g. because it is a JS file with TS syntax, or it...
Read more >Uncaught SyntaxError: Unexpected token < - JavaScript - iDiallo
Uncaught SyntaxError: Unexpected token <. Aug 24 2016 Ibrahim Diallo. This is a common error in JavaScript, and it is hard to understand...
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 FreeTop 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
Top GitHub Comments
I have the same error today after upgrading to 8.0.1 from 2.x.
I had to remove Line 5
react-native": "src/index.ts",
from node_modules/react-native-device-info/package.json to make it work.I had a similar issue. I upgraded it from 2.1.2 to the 8.4.4 version and my react-native version is (0.59.10). I don’t use typescript in my project. Having the following dev dependencies fixed this issue for me.
“devDependencies”: { “@babel/core”: “^7.9.0”, “@babel/runtime”: “^7.9.2”, //other dev dependencies }
Found this solution from the accepted answer from this, https://stackoverflow.com/questions/62270438/react-native-error-bundling-failed-syntaxerror-react-native-projects-appone-n