2
SyntaxError: Unexpected token u in JSON at position 0
    at JSON.parse (<anonymous>)

The error comes from almost any component -- each time I comment out the component that generates the error, the error comes from another one... and they all stem from at handle (node_modules/worker-farm/lib/child/index.js:44:8) So I can't run any tests.

I get this for even just the default App.test.js in Create React App. This is react 15.3.2.

These should be the relevant parts of my package.json:

"dependencies": {
  "react": "15.3.2",
  "react-dom": "15.3.2",
},

"devDependencies": {
  "enzyme": "^3.6.0",
  "enzyme-adapter-react-15.4": "^1.1.0",
  "react-addons-test-utils": "0.14.8",
},
skyboyer
  • 22,209
  • 7
  • 57
  • 64
  • Remove the trailing "," from your `package.json` - ie, "react-dom": "15.3.2", -> "react-dom": "15.3.2" and "react-addons-test-utils": "0.14.8", -> "react-addons-test-utils": "0.14.8" – Dacre Denny Sep 27 '18 at 20:19
  • https://stackoverflow.com/questions/46613243/uncaught-syntaxerror-unexpected-token-u-in-json-at-position-0 – Aaron Sep 28 '18 at 05:40
  • Thanks but there actually aren't any trailing commas. I only posted a small snipit of the package.json - my bad – Jon Sanders Sep 28 '18 at 11:46

1 Answers1

0

I recently came across this issue with translation files (en.json). I found trailing commas the issue behind this.

  1. Run the ESlint on your file.
  2. Check red areas. It could be trailing commas, Invalid escape character in string (\ n instead of \n)
  3. Fix the issues.

It should be good to go

Amit
  • 2,389
  • 22
  • 29