Search code examples
node.jsreactjsnpmnpm-installyarnpkg

I cannot install any package using npm (need for react-router-dom)


When I try to install something in the beginning I see I some gibberish text and It is taking too long and in the end it is giving me an error. On top of that Yarn is not helping.

 npm version 6.14.10,  node v14.15.1 ,  yarn v * 1.22.10

I see this gibberish text when I tried to install with yarn.

yarn add v1.22.10
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
error An unexpected error occurred: "C:\\Users\\DavrService™\\AppData\\Local\\Yarn\\Cache\\v6\\npm-hoist-non-react-statics-3.3.2-ece0acaf71d62c2969c2ec59feff42a4b1a85b45-integrity\\node_modules\\hoist-non-react-statics\\.yarn-metadata.json: Unexpected token \u0000 in JSON at position 0".
info If you think this is a bug, please open a bug report with the information provided in "D:\\real\\test\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

When I tried with npm it says npm warn deprecated and this kind of stuff.


Solution

  • Run these commands (In order):

    npm cache clear -force
    
    npm uninstall -g create-react-app
    
    npm i -g create-react-app
    
    npm i -g npm
    
    npx create-react-app myapp