0

I restarted working on my website and it keeps giving this error I'm not sure why because I never edited the package.json file. Btw I'm doing my project with react.

error that shows up whenever I do npm start or use codesandbox to run my code

this is my package.json file

{
  "name": "profile-project",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@fortawesome/fontawesome-svg-core": "^6.1.1",
    "@fortawesome/free-brands-svg-icons": "^6.1.1",
    "@fortawesome/free-solid-svg-icons": "^6.1.1",
    "@fortawesome/react-fontawesome": "^0.1.18",
    "@testing-library/jest-dom": "^5.16.4",
    "@testing-library/react": "^13.1.1",
    "@testing-library/user-event": "^13.5.0",
    "bootstrap": "^5.1.3",
    "font-awesome": "^4.7.0",
    "react": "^18.0.0",
    "react-bootstrap": "^2.4.0",
    "react-dom": "^18.0.0",
    "react-icons": "^4.3.1",
    "react-router-dom": "6",
    "react-scripts": "5.0.1",
    "sass": "^1.51.0",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

1 Answers1

-1

I don't know much about your project, but that is the typical error given when something is expecting JSON and is given HTML instead. This commonly occurs when an API request is made incorrectly and an index.html is returned, the API is running PHP and it errors and gives an error message in HTML, etc.

If it worked before but doesn't now, then something must have changed. Browsers almost never break backwards compatibility, so it's most likely something in your project. Did you make absolutely no changes whatsoever since you last worked with it? (Not even a dependency update.)

Go through these steps, and let us know what happens:

  1. Are you sure you have not changed anything since it worked?
  2. Are there any error messages in the browser console?
  3. Does your project have any other components? If so, what are the contents of the components mentioned in that error message?
  4. Based on this, do you have a base tag in the head of your index.html or equivalent? E.g. <base href="/" />

Also maybe relevant: Webpack Issue #2541.

Darryl Noakes
  • 2,207
  • 1
  • 9
  • 27
  • I uploded my package.json file – Noman Patel May 30 '22 at 18:40
  • 1
    "_No one can help if we do not know more about the project_" - If a question doesn't contain sufficient information to be able to answer it (with a high degree of certainty), then the question should be closed until that information is provided. Stack Overflow is not a help desk. The information from the first revision of your question is basically a repetition of what is already explained [here](https://stackoverflow.com/questions/37280274/syntaxerror-unexpected-token-in-json-at-position-0) (in which case it should be closed [as a duplicate](https://stackoverflow.com/help/duplicates)). – Ivar May 30 '22 at 19:40
  • 1
    The rest of the answer is essentially "how to debug" which isn't what the question is asking and doesn't really belong in an answer on Stack Overflow. – Ivar May 30 '22 at 19:40
  • 1
    Got you, @Ivar. Thanks for explaining. I have often seen others asking for more info here, but I guess I should have done so in comments on the question. – Darryl Noakes May 30 '22 at 19:56