SyntaxError: Unexpected end of JSON input

Hi I was working on a discord bot project and then my bot wouldn’t refresh anymore, it kept saying this from the console

SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /opt/watcher/source/app-picker.ts:105:37
    at ChildProcess.exithandler (child_process.js:285:7)
    at ChildProcess.emit (events.js:189:13)
    at ChildProcess.EventEmitter.emit (domain.js:441:20)
    at maybeClose (internal/child_process.js:970:16)
    at (internal/child_process.js:389:11)
    at Socket.emit (events.js:189:13)
    at Socket.EventEmitter.emit (domain.js:441:20)
    at Pipe._handle.close (net.js:597:12)

I don’t know if someone can fix this
if you can thanks

I am not experienced enough to know for sure what you’re parsing, but if I’m not wrong you’re trying to parse “<anonymous>” as JSON? That’s not a JSON data.

Even if i’m wrong and anonymous is actually something else, you surely must be parsing a non-JSON data using JSON.parse()

Go to your project and check what is at /opt/watcher/source/app-picker.ts:105:37 for me.

Hope this helps!

I was wrong, that file is hidden from you. Can you show the code where you’re calling JSON.parse()?

I don’t actually know where to find app-picker.ts.

Somewhere in your project its trying to either parse something that is not a string or trying to parse an empty string.

I believe you’re parsing something that is not JSON. Most likely, it’s a variable that you expect to be JSON but isn’t. You have to debug yourself since we’re not able to see your code

Do you have any JSON files in your project? If so, are any empty? If they are empty, put 2 curly brackets in like so: {}