question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Syntax error: Unexpected token in src/index.ts

See original GitHub issue

During 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:closed
  • Created 3 years ago
  • Comments:27

github_iconTop GitHub Comments

13reactions
vignesarulcommented, Jan 27, 2021

I have the same error today after upgrading to 8.0.1 from 2.x.

I had to remove Line 5react-native": "src/index.ts", from node_modules/react-native-device-info/package.json to make it work.

8reactions
thilinaacommented, Nov 3, 2021

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found