Home > other >  SyntaxError: Error parsing c:\Users\myUser\package.json: Unexpected string in JSON at position 55
SyntaxError: Error parsing c:\Users\myUser\package.json: Unexpected string in JSON at position 55

Time:07-28

I'm trying to understand what this mean :

SyntaxError: Error parsing c:\Users\myUser\package.json: Unexpected string in JSON at position 55.

On Visual Studio Core I only need to use this API : https://openlibrary.org/works/OL82563W.json

I wrote this code :

import { default as fetch } from "node-fetch";
globalThis.fetch = fetch

fetch('https://openlibrary.org/works/OL82563W.json');
    .then((data) =>{
        console.log(data)
    .catch((error) => {
        console.error(error);
      });
});

and this is what there is inside that package :

{
  "dependencies": {
    "node-fetch": "^3.2.9"
  }
  "type": "module"
}

CodePudding user response:

You need to separate keys by comma as follow:

{
  "dependencies": {
    "node-fetch": "^3.2.9"
  },
  "type": "module"
}

CodePudding user response:

If your package.json was not a valid JSON then you can try to fix the JSON structure, using online tools like and validate the JSON

  • Related