Search code examples
node.jsreactjsnpmcreate-react-app

error installing create-react-app using npm & error when using npm init react-app


I'm trying to install create-react-app but It does not work

$ npm install create-react-app
npm ERR! code ECONNREFUSED
npm ERR! errno ECONNREFUSED
npm ERR! FetchError: request to https://registry.npmjs.org/create-react-app failed, reason: connect ECONNREFUSED 127.0.0.1:8080
npm ERR!     at ClientRequest.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\index.js:68:14)
npm ERR!     at ClientRequest.emit (events.js:315:20)
npm ERR!     at onerror (C:\Program Files\nodejs\node_modules\npm\node_modules\agent-base\index.js:101:9)
npm ERR!     at callbackError (C:\Program Files\nodejs\node_modules\npm\node_modules\agent-base\index.js:123:5)
npm ERR!     at processTicksAndRejections (internal/process/task_queues.js:97:5)
npm ERR!  FetchError: request to https://registry.npmjs.org/create-react-app failed, reason: connect ECONNREFUSED 127.0.0.1:8080
npm ERR!     at ClientRequest.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\index.js:68:14)
npm ERR!     at ClientRequest.emit (events.js:315:20)
npm ERR!     at onerror (C:\Program Files\nodejs\node_modules\npm\node_modules\agent-base\index.js:101:9)
npm ERR!     at callbackError (C:\Program Files\nodejs\node_modules\npm\node_modules\agent-base\index.js:123:5)
npm ERR!     at processTicksAndRejections (internal/process/task_queues.js:97:5) {
npm ERR!   type: 'system',
npm ERR!   errno: 'ECONNREFUSED',
npm ERR!   code: 'ECONNREFUSED'
npm ERR! }
npm ERR!
npm ERR! If you are behind a proxy, please make sure that the
npm ERR! 'proxy' config is set properly.  See: 'npm help config'

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\LENOVO\AppData\Roaming\npm-cache\_logs\2020-08-30T19_12_06_047Z-debug.log


I'm getting this error. I tried npm cache clean --force but nothing happened

When I try to use npm init react-app my-app I git this error

$ npm init react-app my-app

Creating a new React app in C:\Users\LENOVO\Desktop\WebDev\React\my-app.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...

npm ERR! code ECONNREFUSED
npm ERR! errno ECONNREFUSED
npm ERR! FetchError: request to https://registry.npmjs.org/cra-template failed, reason: connect ECONNREFUSED 127.0.0.1:8080
npm ERR!     at ClientRequest.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\index.js:68:14)
npm ERR!     at ClientRequest.emit (events.js:315:20)
npm ERR!     at onerror (C:\Program Files\nodejs\node_modules\npm\node_modules\agent-base\index.js:101:9)
npm ERR!     at callbackError (C:\Program Files\nodejs\node_modules\npm\node_modules\agent-base\index.js:123:5)
npm ERR!     at processTicksAndRejections (internal/process/task_queues.js:97:5)
npm ERR!  FetchError: request to https://registry.npmjs.org/cra-template failed, reason: connect ECONNREFUSED 127.0.0.1:8080
npm ERR!     at ClientRequest.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\index.js:68:14)
npm ERR!     at ClientRequest.emit (events.js:315:20)
npm ERR!     at onerror (C:\Program Files\nodejs\node_modules\npm\node_modules\agent-base\index.js:101:9)
npm ERR!     at callbackError (C:\Program Files\nodejs\node_modules\npm\node_modules\agent-base\index.js:123:5)
npm ERR!     at processTicksAndRejections (internal/process/task_queues.js:97:5) {
npm ERR!   type: 'system',
npm ERR!   errno: 'ECONNREFUSED',
npm ERR!   code: 'ECONNREFUSED'
npm ERR! }
npm ERR!
npm ERR! If you are behind a proxy, please make sure that the
npm ERR! 'proxy' config is set properly.  See: 'npm help config'

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\LENOVO\AppData\Roaming\npm-cache\_logs\2020-08-30T19_37_47_138Z-debug.log

Aborting installation.
  npm install --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.

Deleting generated file... package.json
Deleting my-app/ from C:\Users\LENOVO\Desktop\WebDev\React
Done.

please, anyone, help.


Solution

  • Create React App using the following commands;

    npx create-react-app my-app
    
    
    npm init react-app my-app
    
    yarn create react-app my-app
    

    Create React App

    Try this to fix your proxy

    npm config set proxy null
    npm config set https-proxy null
    npm config set registry http://registry.npmjs.org/