'Installing create-react-app gives npm ERR! shasum check failed and npm ERR! Unexpected end of JSON input while parsing near '...mojOzGIEI2rg0m24Yb5Oq'

Errors when i use sudo npm install create-react-app -g npm ERR! Linux 4.13.0-39-generic npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "i" "create-react-app" "-g" npm ERR! node v6.11.4 npm ERR! npm v3.5.2

npm ERR! shasum check failed for /tmp/npm-16477-77596b49/registry.npmjs.org/tar/-/tar-2.2.1.tgz npm ERR! Expected: 8e4d2a256c0e2185c6b18ad694aec968b83cb1d1 npm ERR! Actual: 5eb06eb521673d0940a4deb11baf89d62647f193 npm ERR! From: https://registry.npmjs.org/tar/-/tar-2.2.1.tgz

when use npm install create-react-app - npm-version : 6.0.0 - node-version: 8.11.1 error is:
npm ERR! Unexpected end of JSON input while parsing near '...mojOzGIEI2rg0m24Yb5Oq'

npm ERR! A complete log of this run can be found in: npm ERR! /home/dilipcoder/.npm/_logs/2018-05-05T11_34_14_721Z-debug.log

i have already tried these options

  • npm cache clean --force
  • reinstalling npm and node
  • switching different version of npm

error which I get while installing create-react-app other packages installed properly



Solution 1:[1]

the error npm ERR! shasum check failed and npm ERR! Unexpected end of JSON input while parsing near'....' ,   will be solved by switching npm reigistry from the list of given npm registry.

List of Npm registry:

To switch just type

npm config set registry "https://registry.npmjs.com/"

Replace the registry url with the above urls check which one works for you.

After That:

  • npm cache clear --force
  • npm cache verify
  • now error will be solved.

    Solution 2:[2]

    "npm cache clean --force" didn't work for me but removing package-lock.json worked. https://github.com/vuejs-templates/webpack/issues/990#issuecomment-395750082

    Solution 3:[3]

    Error:

    SyntaxError: Unexpected end of JSON input while parsing near

    Removing package-lock.json worked for me.

    Add Powershell script or Linux script as below,

    Powershell:

    Remove-Item package-lock.json  -Force
    

    Linux:

    rm -rf package-lock.json
    

    Path In Azure Devops:

    $(System.DefaultWorkingDirectory)\appName\appName\ClientApp\node_modules'
    

    Note - appName is an example you can add a path as per your source code.

    Sources

    This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

    Source: Stack Overflow

    Solution Source
    Solution 1 Ben Smith
    Solution 2 Ph?m Hoàng D?
    Solution 3 FortyTwo