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 Socket.stream.socket.on (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 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
I have an existing python glitch which worked great until I added a package.json to it. I was hoping to start using node for some client-side stuff. After adding my package.json, it enabled node on my glitch just fine, but every time it tries to restart, I get this in my log.
SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at /opt/watcher/source/app-picker.ts:107:39
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 Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
I disabled the watch.json by renaming it… so it’s not that…
and when I rename or delete the package.json, everything works again
I tried to replicate this using a new html only glitch then added a package.json to it… and that worked fine. I’m not sure what my python glitch is missing. https://glitch.com/edit/#!/ld-space-camp-0
I figured it out. Turns out if you want to run both Python and Node in the same container, you’ll have to remove or rename requirements.txt because when Glitch sees a requirements.txt in the root dir, it will try to run start.sh. This was very helpful: Python and Javascript in same project?
ok so i am storing data in a file not in any database and it was working fine for 2,3 data elemenst but somehow i dunno when adn how my data got deleted from the file and then it keep showing me this data bcz i was displaying the empty json file so what i did that i deleted the file and when i run the code it got created again with data inside and it worked for me