Node.js and JSON syntax error in a p5 project

Hello all

has anyone found success deploying a Node.js/p5 project to Bluehost? I have a working project (locally and on heroku and gltich) but the same project craps out on Bluehost with an “Uncaught (in promise) SyntaxError: Unexpected token c in JSON at position 0” error.
MO

you need to clarify what you are trying a bit more - does Bluehost allow server side scripts (e.g., nodejs) or is it only front end? Also what do you mean by node.js/p5.js - is p5.js loaded as an npm module in node.js, or is it used as front end separately from node.js? And where do you get that error - on the server console or on the browser?

hey thank you. yes, Bluehost supports node.js and I installed it on the host. p5 is not loaded as a module. only front end. I get the error in the browser console. The node.js app launches without error (“Listening on port 3000”)

ok so I privately received the link - but still what I see is the front end so it’s still hard to debug from the given information.

  • first of all I think this is not really related to p5.js so for further questions perhaps it’s better asking on other places
  • however given that you cannot share a link, you should make a small demo to illustrate an issue (also something written in the guideline… “Is your problem isolated?”) which will help others to see the issue + for yourself to spot where the bug is happening. Also try console.log the object that is giving the error
  • from the given info that the webpages are served but fetch is failing, I’m guessing that pages are served statically by apache or nginx and loaded properly, but node.js is not accessible. On Heroku or Glitch they take care of reverse proxy but you may need to set up the server by yourself:

http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypassreverse

but again I feel this is no longer related to p5.js (correct me if I’m wrong) so I don’t know if this is the right place to discuss further. I see you are using ml5.js so maybe you can ask informally on their discord server - or coding train discord - if anyone can help you. I’d like to help but please don’t DM me on the forum, just for the sake of transparency :slight_smile:

1 Like

Hi Micuat

Apologies for the dm. Just couldn’t share the link in public, and feeling desperate with a fast-approaching deadline. I’m new to node.js and have little grasp of the backend in general. You are correct that this is not a p5 problem. I do however need to store and retrieve the images coming out of p5 and this is where things fall apart. I have found a new host (evennode) which I think will be better. Thanks for the time and again, sorry for the bother.

cheers
MO