Unexpected token < in JSON at position 0

Hi Glitch Support Team!
Thanks for partnering with FreeCodeCamp.org to spread code literacy and tech love.
I’ve spent quite a few hours struggling to complete the first Node.js/npm assignment, namely: adding a single key/value pair to a boilerplate node project’s package.json file.
The full transcript of my ever-escalating troubleshooting attempts can be found at the official FreeCodeCamp forum link below, and I plan to cross-post this thread there for the benefit of future campers.
Any advice/support you can offer would be a huge help - as it stands now, the thought of investing more time in Glitch-hosted projects does not inspire much confidence.
This is particularly disheartening, as this section is required for the FCC certification.
Anyway, here’s the link, adjusted to where the issue begins: :point_down:
https://www.freecodecamp.org/forum/t/managing-packages-with-npm-how-to-use-package-json-the-core-of-any-node-js-project-or-npm-package/198736/20
Thanks,
-Bernard

2 Likes

Hey @BernardFaucher, welcome to the Glitch forum!

I’m sorry for the bother and trouble you’ve encountered. We’ll take a look at that thread and get back to you as soon as we can!

2 Likes

FWIW, the issue remains a blocker, across projects and assignments. Reproduction steps: Logged out & back in w/Github. Cloned a brand new project from boilerplate. Added a new key/val pair. Copied public URL into FCC solution field. Unexpected token < in JSON at position 0.


As a sanity check, I also went to the FCC repo to see if there was anything wrong with the assignment’s test script. Seems legit, but you’re welcome to check for yourselves.

1 Like

Hi Bernard, any word on this issue being resolved any time soon? Is the FCC staff working on it, maybe alternative resolutions?

Hi @carlarsmendes

I received no guidance or explanation from the Glitch support team on this issue whatsoever - I’m truly sorry if you are likewise afflicted.
By way of an “alternative resolution,” I’m happy to report that I was able to complete the APIs & Microservices certification by moving off of Glitch, entirely.

If you’re interested in doing the same, let me outline what you’re in for:
First off, you’re going to be developing your back-end code in the Ruby language using the Rails framework.
Secondly, instead of deploying your apps/microservices on Glitch, you’ll be using Heroku.
Finally, when called for, you’ll be using postgresql as your database provider instead of MongoDB.

Now, that might sound like a lot, but I promise that if you’re developing on MacOS or Linux, the whole experience will be a joy - things will “just work,” and when they don’t, error messages will be clear and helpful!
If you’ve only got access to a Windows environment, by contrast, I’d recommend that you not even try The Rails Way™ until you’ve set up an Ubuntu virtual machine or partition on which to develop.

For guidance, you can find my code to the 5 API challenges on GitHub from https://github.com/BernardFaucher/fcc_proj_0 to github[dot]com/BernardFaucher/fcc_proj_4
Correspondingly, you can find the deployed apps on Heroku from https://fcc-proj-0.herokuapp.com to fcc-proj-4[dot]herokuapp[dot]com
One important note: Since these are APIs built to spec, the root page will usually give you an HTTP ERROR 404; to see the solution, you’ll need to add the path stipulated by the project requirements.
For example, in the first project, fcc-proj-0[dot]herokuapp[dot]com/api/timestamp and so on.
Where the FCC spec calls for a POST request, I used a beautiful and intuitive little app called Postman to send post data to my api.

Teaching Rails in any real depth is outside the scope of this post, but here are some tips to get you started.
To build the skeleton of an API project, you’ll use the command rails new project_name --api --database=postgresql - so easy! If the project calls for more than just an API, you can omit the --api flag.
To spin up a development server, navigate to your new project cd project_name and run rails s at which point, you’ll be able to visit localhost:3000 in you browser or in Postman, when called for.
To build routes, you’ll be making additions to /config/routes.rb in the shape of verb path controller#method - the boilerplate code in your routes.rb file provides a URL to where you can learn more about what that means, but it’s elegant and simple.
Your code will, by and large, live in a type of file that Rails calls a controller, located in /app/controllers - you can create new controllers from the terminal with rails g controller controller_name - the Rails docs will guide you through the process and answer any questions.
Some projects will require you to make calls to your database, requiring you to create tables that Rails calls Models to store user data.
For these cases, you’ll use rails g model pluralized_model_name column_name:data_type - for example rails g model users name:string - as a bonus, you’ll get some columns for free like id and created_at
If your API uses a database, you’ll want to run rake db:create from the terminal before running rails s the first time when developing locally, and when you make a change to your database like adding a new Model, you’ll also need to run rake db:migrate and restart your rails server. The docs will tell you more.
To get started with Heroku, you’ll first sign up for a free account, then will install the Heroku command line tools - instructions are on their getting started page.
Before doing so, make sure you’ve created a new repo on your GitHub page and added/committed your files - you’ll see the appropriate commands outlined on the new repo GitHub page.
Heroku integrates neatly with Git, so to deploy the code committed to your master branch for the first time you’ll run heroku create project-name then git push heroku master then heroku open to open your browser to see your code live.

There’s plenty of stuff I’ve glossed over for the sake of brevity, but to learn more, I can’t speak highly enough about the Rails and Heroku documentation, nor their unbelievably helpful and respectful communities. Feel free to check out my code on GitHub if you get stuck, and if all else fails, you’re welcome to reach out to me on the FCC forums directly @BernardFaucher

I’ve since moved on to the final InfoSec and QA module of FCC and have, perhaps unsurprisingly, encountered nothing but errors and confusion when trying to establish an mLab connection to Glitch.
Therefore, I’ll be looking at using the Heroku add-on for mLab for this certification, too - I might circle back to this post on completion to let folks know how that went and whether it might be worth their time.

All the best, fellow camper
-B

Hi everyone!
I just finished first lesson and spend only hour :joy:
I clicked on “show” on the top of code page in glitch and choose “next to the code” option, then clicked on “share” button and choose “live up”.
Paste it in fcc and you will pass the test!