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.

SyntaxError: Unexpected token < in JSON at position 0

See original GitHub issue

Environment Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

from my package.json:

"dependencies": {
    "@angular/animations": "~8.2.0",
    "@angular/common": "~8.2.0",
    "@angular/compiler": "~8.2.0",
    "@angular/core": "~8.2.0",
    "@angular/forms": "~8.2.0",
    "@angular/platform-browser": "~8.2.0",
    "@angular/platform-browser-dynamic": "~8.2.0",
    "@angular/router": "~8.2.0",
    "@nativescript/theme": "~2.3.0",
    "nativescript-angular": "~8.21.0",
    "nativescript-ui-sidedrawer": "~8.0.0",
    "reflect-metadata": "~0.1.12",
    "rxjs": "^6.4.0",
    "tns-core-modules": "~6.5.0",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular/compiler-cli": "~8.2.0",
    "@nativescript/schematics": "^9.0.0",
    "@ngtools/webpack": "~8.2.0",
    "codelyzer": "~4.5.0",
    "nativescript-angular-cli": "^0.1.9",
    "nativescript-dev-webpack": "~1.5.0",
    "node-sass": "^4.7.1",
    "tslint": "~5.19.0",
    "typescript": "~3.5.3"
  },

Describe the bug Interesting issue- my project is working fine yesterday. today i run it and all of the sudden I start getting an error when connecting to my app with the nativescript playground previewer. 🤔

To Reproduce

by running tns preview

Expected behavior it should compile and work and be the beautiful former self that it was!  🙃

Sample project https://github.com/JimLynchCodes/Study-App/tree/master/study-app

Additional context any advice on why this is happening and what i should do is appreciated. thanks!

btw I have noticed that many times when testing on a physical ios device via tns preview the thing just crashes with no helpful error message in the console, no line number, etc.

here is the output i am seeing after using the playground to scan the barcode:

**Preparing project...
File change detected. Starting incremental webpack compilation...

webpack is watching the files…

Hash: cc19848af376aacf6e72
Version: webpack 4.27.1
Time: 4846ms
Built at: 08/13/2020 11:41:27 PM
                   Asset       Size   Chunks             Chunk Names
                    0.js   36.6 KiB        0  [emitted]  
                    1.js     36 KiB        1  [emitted]  
                    2.js   13.3 KiB        2  [emitted]  
                    3.js   15.7 KiB        3  [emitted]  
                    4.js   14.8 KiB        4  [emitted]  
                    5.js   11.6 KiB        5  [emitted]  
               bundle.js    506 KiB   bundle  [emitted]  bundle
 fonts/fa-brands-400.ttf    131 KiB           [emitted]  
fonts/fa-regular-400.ttf   39.1 KiB           [emitted]  
  fonts/fa-solid-900.ttf    204 KiB           [emitted]  
            package.json  112 bytes           [emitted]  
              runtime.js     73 KiB  runtime  [emitted]  runtime
               vendor.js   21.2 KiB   vendor  [emitted]  vendor
Entrypoint bundle = runtime.js vendor.js bundle.js
[../$$_lazy_route_resource lazy recursive] ../$$_lazy_route_resource lazy namespace object 160 bytes {bundle} [built]
[./app.scss] 121 KiB {bundle} [built]
[./app/app-routing.module.ts] 1.97 KiB {bundle} [built]
[./app/app.component.html] 2.29 KiB {bundle} [built]
[./app/app.component.ts] 1.99 KiB {bundle} [built]
[./app/app.module.ts] 3.51 KiB {bundle} [built]
[./app/data/question-bank.ts] 41.7 KiB {bundle} [built]
[./app/mock-exam/mock-exam.module.ts] 760 bytes {4} [built]
[./app/utils/question-generator/question-generator.service.ts] 3.26 KiB {bundle} [built]
[./main.ts] 1.57 KiB {bundle} [built]
[@angular/core] external "@angular/core" 42 bytes {bundle} [built]
[nativescript-angular/nativescript.module] external "nativescript-angular/nativescript.module" 42 bytes {bundle} [built]
[nativescript-angular/platform] external "nativescript-angular/platform" 42 bytes {bundle} [built]
[nativescript-ui-sidedrawer/angular] external "nativescript-ui-sidedrawer/angular" 42 bytes {bundle} [built]
[tns-core-modules/bundle-entry-points] external "tns-core-modules/bundle-entry-points" 42 bytes {bundle} [built]
    + 43 hidden modules
Webpack compilation complete. Watching for file changes.
Webpack build done!
Project successfully prepared (ios)
Start sending initial files for device hadxain’s iPhone (4DA00FAE-D90B-4D76-8093-F5AB009E6B54).
Successfully sent initial files for device hadxain’s iPhone (4DA00FAE-D90B-4D76-8093-F5AB009E6B54).
SyntaxError: Unexpected token < in JSON at position 0
    at JSON.parse (<anonymous>)
    at PreviewSdkService.<anonymous> (/Users/jlynch/.nvm/versions/node/v13.13.0/lib/node_modules/nativescript/lib/services/livesync/playground/preview-sdk-service.js:100:43)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/jlynch/.nvm/versions/node/v13.13.0/lib/node_modules/nativescript/lib/services/livesync/playground/preview-sdk-service.js:4:58)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

Like I was saying earlier, I have been working on this app for a few weeks now. Everything was fine even yesterday, commited everything to version control, and now today with no git changes I am getting this error. 🤔

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:8
  • Comments:20 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
JimLynchCodescommented, Aug 16, 2020

Yep, works again for me too. thanks!

3reactions
enso-mediacommented, Aug 14, 2020

Same here. Can also be reproduced with an absolutely new created project.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SyntaxError: Unexpected token < in JSON at position 0
This happens when you are running backend and frontend on the same sever (e.g., localhost). To fix that, in the package.json inside your...
Read more >
What Is JSON and How to Handle an “Unexpected Token” Error
“Unexpected token < in JSON at position 0” is the error that I have seen most throughout my time of working as a...
Read more >
How to Fix SyntaxError: Unexpected token < in JSON at ...
Usually this error is caused when your server returns HTML (which typically begins with <DOCTYPE html> or <html> ) instead of JSON. Valid...
Read more >
Unexpected token u in JSON at position 0 Error in JS
The "Unexpected token u in JSON at position 0" error occurs when we pass an undefined value to the JSON.parse or $.parseJSON methods....
Read more >
Unexpected token in JSON at position 0 - Moodle.org
Re: Unexpected token in JSON at position 0 ... This usually means that an error has been returned and that's not valid JSON....
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