Managing Packages with Npm - How to Use package.json

I have the following error:

Unexpected token < in JSON at position 0

this is the json code,
{
“//1”: “describes your app and its dependencies”,
“//2”: “https://docs.npmjs.com/files/package.json”,
“//3”: “updating this file will download and update your packages”,
“name”: “hello-express”,
“author”: “Sammy Khaleel”,
“version”: “0.0.1”,
“description”: “A simple Node app built on Express, instantly up and running.”,
“main”: “server.js”,
“scripts”: {
“start”: “node server.js”
},
“dependencies”: {
“express”: “4.16.3”
},
“engines”: {
“node”: “8.x”
},
“repository”: {
“url”: “https://glitch.com/edit/#!/hello-express
},
“license”: “MIT”,
“keywords”: [
“node”,
“glitch”,
“express”
],
}

That error is not coming from this file.

So, from where? there is not enough info in this module to help me troubleshoot the problem.

1 Like

This error is when JSON is expected, but HTML received.

You trying parsing JSON.parse(youvar) a not stringified object.in somewhere in your code.

I am not writing any code it is the first challenge in “managing packages with npm” module we were asked to write author name in package.json in a file hosted by glitch and then we should submit the link of glitch.

this is the link to the challenge:
https://learn.freecodecamp.org/apis-and-microservices/managing-packages-with-npm/how-to-use-package-json-the-core-of-any-node-js-project-or-npm-package

Heya, your quotation marks are the wrong type, they shouldn’t be “” they should be "

Other than that, you also have a trailing comma near the end

package.json must be valid JSON

1 Like

You should give a link to glitch project. click on share and tab code.
and there migth be < somewhere in this file you accidently type try ctrl+f and look for <

I think the problem is with my link, may be I should sign up for an account on glitch. but in the challenge there is no mention on that.
I still unable to solve the issue

I put the link to the actual app and the test is completed without the previous error but I still have an error that now I am unable to reproduce because glitch now prevent me from loading the app because I made too much requests (or that is my understanding).
Why this module is been abandoned when I tried to get a hint or ask for help I found this: This is a stub. Help our community expand it. any moderators here for the rescue?

Did you check your quotation marks?

I’ve provided the code above, you can see that it is a valid JSON.

your quotation marks are the wrong type, they shouldn’t be “” they should be "

Did you check that they’re the right type? As in not slanted quotation marks but instead the ASCII quotation mark

Copying your above code definitely doesn’t work due to that

This is the freecodecamp font that renders the double quote this way.

Can you post it within triple backticks so we can see it unformatted?


{
  "//1": "describes your app and its dependencies",
  "//2": "https://docs.npmjs.com/files/package.json",
  "//3": "updating this file will download and update your packages",
  "name": "hello-express",
  "author": "Sammy Khaleel",
  "version": "0.0.1",
  "description": "A simple Node app built on Express, instantly up and running.",
  "main": "server.js",
  "scripts": {
    "start": "node server.js"
  },
  "dependencies": {
    "express": "^4.16.4"
  },
  "engines": {
    "node": "8.x"
  },
  "repository": {
    "url": "https://glitch.com/edit/#!/hello-express"
  },
  "license": "MIT",
  "keywords": [
    "node",
    "glitch",
    "express"
  ]
}


It’s really odd, but copypasting that works for me locally

I wonder if there’s a line-endings problem or something really daft like that, but that doesn’t seem likely if you’re editing in glitch directly

1 Like

So I struggled with the same question for an hour or so until I went to the fcc project github link and saw how different the files are compared to the glitch project that popped up.

You need to start the project from this code. I did not want to do the whole clone and link it all to glitch so I just created the files and copied the contents into a glitch project. Lo and behold it works now.

Here’s my working glitch project: https://onyx-rake.glitch.me/

I hope it helps!

2 Likes

Make sure you are submitting the actual application URL and not the edit URL. When editing your project on Glitch, click Show Live at the top left, and submit that URL to FCC.

2 Likes

Thanks!

This is what worked for me. The “share” link that you see in the glitch editor doesn’t share your live project url it shares the link to edit your project on glitch