npm ERR! Unexpected token < in JSON at position 12842

前端 未结 11 1703
借酒劲吻你
借酒劲吻你 2021-01-01 10:59

Every time I try installing any package or even if I try doing npm install I keep getting this error. I have no idea why I am getting the error. I am totally ne

相关标签:
11条回答
  • 2021-01-01 11:52

    For posterity, my issue was that we switched from using nexus to artifactory. You can find that out by using npm config get registry which in my case printed out the URL to our old nexus repository. Then use npm config set registry https://artifactory.your-company.com/artifactory/api/npm/npm/ and that resolved my issue.

    0 讨论(0)
  • Deleting the package-lock.json didn't work for me. The issue was an extra comma in my package.json file.

    Try copying your json file into jsonlint.com. It will give you more information to show you if the issue you're having is truly a syntax error.

    Checkout this article https://dev.to/redslug/7-solutions-to-ejsonparse-or-unexpected-token-npm-install-error-20nh if none of the answers here help. It helped me.

    0 讨论(0)
  • 2021-01-01 11:55

    It's because of a package-lock.json merge conflict.

    Delete the file, delete node_modules, and run npm install to solve the problem:

    rm package-lock.json
    rm -rf node_modules
    npm install
    
    0 讨论(0)
  • 2021-01-01 12:04

    Try this command "npm cache verify" if removing package.lock does not work

    0 讨论(0)
  • 2021-01-01 12:04

    For me it happened, because I have added an entry in the script section of package.json file. Check your pachage.json file if you already added any item to the script section and try to remove or fix it. Also check if there is no any kamma at the end of object right before } close bracket.

    0 讨论(0)
提交回复
热议问题