npx create-react-app projectName causing error

2.4k Views Asked by At

I am creating a react app using first command; npm init then second npx create-react-app projectName, however it is giving this error:

npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR! network request to http://registry.npmjs.org/create-react-app failed, reason: connect ETIMEDOUT 104.16.22.35:80
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network '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\amrish patidar\AppData\Roaming\npm-cache\_logs\2020-12-17T07_28_05_673Z-debug.log

My npm config list is below

npm config list

    ; cli configs
    metrics-registry = "http://registry.npmjs.org/"
    scope = ""
    user-agent = "npm/6.14.9 node/v14.15.2 win32 x64"
    
    ; userconfig C:\Users\amrish patidar\.npmrc
    registry = "http://registry.npmjs.org/"
    strict-ssl = true
    
    ; builtin config undefined
    prefix = "C:\\Users\\amrish patidar\\AppData\\Roaming\\npm"
    
    ; node bin location = C:\Program Files\nodejs\node.exe
    ; cwd = C:\Users\amrish patidar
    ; HOME = C:\Users\amrish patidar
    ; "npm config ls -l" to show all defaults.

debug.log file

 C:\Users\amrish patidar\AppData\Roaming\npm-cache\_logs\2020-12-17T07_28_05_673Z-debug.log


    0 info it worked if it ends with ok
    1 verbose cli [
    1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
    1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
    1 verbose cli   'install',
    1 verbose cli   'create-react-app'
    1 verbose cli ]
    2 info using [email protected]
    3 info using [email protected]
    4 verbose config Skipping project config: C:\Users\amrish patidar/.npmrc. (matches userconfig)
    5 verbose npm-session c45391ce1f743672
    6 silly install loadCurrentTree
    7 silly install readLocalPackageData
    8 silly fetchPackageMetaData error for create-react-app@latest request to http://registry.npmjs.org/create-react-app failed, reason: connect ETIMEDOUT 104.16.17.35:80
    9 timing stage:rollbackFailedOptional Completed in 1ms
    10 timing stage:runTopLevelLifecycles Completed in 133456ms
    11 verbose type system
    12 verbose stack FetchError: request to http://registry.npmjs.org/create-react-app failed, reason: connect ETIMEDOUT 104.16.17.35:80
    12 verbose stack     at ClientRequest.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\index.js:68:14)
    12 verbose stack     at ClientRequest.emit (events.js:315:20)
    12 verbose stack     at Socket.socketErrorListener (_http_client.js:469:9)
    12 verbose stack     at Socket.emit (events.js:315:20)
    12 verbose stack     at emitErrorNT (internal/streams/destroy.js:106:8)
    12 verbose stack     at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    12 verbose stack     at processTicksAndRejections (internal/process/task_queues.js:80:21)
    13 verbose cwd C:\Users\amrish patidar
    14 verbose Windows_NT 10.0.19041
    15 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "create-react-app"
    16 verbose node v14.15.2
    17 verbose npm  v6.14.9
    18 error code ETIMEDOUT
    19 error errno ETIMEDOUT
    20 error network request to http://registry.npmjs.org/create-react-app failed, reason: connect ETIMEDOUT 104.16.17.35:80
    21 error network This is a problem related to network connectivity.
    21 error network In most cases you are behind a proxy or have bad network settings.
    21 error network
    21 error network If you are behind a proxy, please make sure that the
    21 error network 'proxy' config is set properly.  See: 'npm help config'
    22 verbose exit [ 1, true ]
3

There are 3 best solutions below

0
On

go through the all comment by @Amit K Khanchandani . are might helpful in your case .

first uninstall nodejs and npm . next install latest version of both . than run npx create-react-app projectname if you got the error that package.json file is not present . very import point : ""than check your system user name if it contain space than it was the cause of problem . because of space present in username you can not use the cmd npx create-react-app projectname.

use this cmd : npm install -g create-react-app(only once) now you can create project with npx create-react-app projectname

9
On

maybe you are behind some proxy,

try this out

go to settings>Network and Internet>Proxy and then off Automatically detect settings under Automatic proxy setup on Windows. And then it should work fine

0
On

If you have installed Node using Snap on Linux. I solved the problem by uninstalling Nodejs using Snap

sudo snap remove node

And reinstall using apt.

sudo apt install nodejs npm