Local server crashing after adding video processing

Help! My backend won’t start after adding video stuff

I’m stuck. My local server was fine until I added a video and ran a Python script to process it. The script’s output should show up on localhost. I installed opencv, Python 3, and pip3 before running it.

Here’s the weird part: my teammates have the same setup and code, but it works for them. When I try npm start, I get this error:

SyntaxError: Unexpected token ' in JSON at position 2
    at JSON.parse (<anonymous>)
    at C:\Third_Year\IBM_project\ibm\back_end\routes\IntensityAPI.js:31:19

I’ve tried clearing the npm cache, deleting node_modules and package-lock.json, and reinstalling everything. No luck.

Any ideas what could be causing this? I’m totally stumped!

hm, sounds like a tricky one.
have u double-checked the JSON format in ur IntensityAPI.js file? maybe theres an extra quote or apostrophe messing things up.
also, try running the python script separately to make sure its outputting valid JSON.
Good luck troubleshooting!

I’ve encountered similar issues before, and it’s often due to subtle differences in environment setups. One thing that saved me was checking the line endings in my files. Windows uses CRLF, while Unix-based systems use LF. This can cause unexpected behavior, especially with JSON parsing.

Try opening your IntensityAPI.js file in a text editor that shows line endings and ensure they’re consistent. Also, check if your Python script is writing the JSON with the correct line endings for your system.

Another potential culprit could be character encoding. Make sure your Python script is outputting UTF-8 encoded JSON. You might need to explicitly set the encoding when writing the file.

If all else fails, try running your backend with verbose logging enabled. This might give you more insight into where exactly the parsing is failing. Good luck!

This issue sounds frustrating. Have you verified the encoding of your Python script’s output? Sometimes, unexpected characters can sneak in, causing JSON parsing errors. I’d recommend checking the raw output of your script to ensure it’s producing valid JSON. Additionally, consider using a JSON validator tool to pinpoint any formatting issues. If the problem persists, you might want to examine any environment variables or system-specific configurations that could be affecting your setup differently from your teammates. Don’t forget to check your Node.js version as well; incompatibilities can sometimes lead to cryptic errors like this.