5

I just got started with react-native project and was trying to setup a demo project to learn react-native. However, I'm unable to create a project through command line.

I used the following command to create react-native project after installing the prerequisite libraries:

react-native init AwesomeProj

I get the following error:

This will walk you through creating a new React Native project in /Users/ketanmalhotra/Documents/Freelance/demo-react/AwesomeProject
Installing react-native...
Consider installing yarn to make this faster: https://yarnpkg.com
npm ERR! Darwin 16.3.0
npm ERR! argv "/usr/local/Cellar/node/6.3.0/bin/node" "/usr/local/bin/npm" "install" "--save" "--save-exact" "react-native"
npm ERR! node v6.3.0
npm ERR! npm  v3.10.3
npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR! syscall connect

npm ERR! network connect ETIMEDOUT 151.101.36.162:443
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is 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! Please include the following file with any support request:
npm ERR!     /Users/ketanmalhotra/Documents/Freelance/demo-react/AwesomeProject/npm-debug.log
{ Error: Command failed: npm install --save --save-exact react-native
    at checkExecSyncError (child_process.js:475:13)
    at execSync (child_process.js:515:13)
    at run (/usr/local/lib/node_modules/react-native-cli/index.js:294:5)
    at createProject (/usr/local/lib/node_modules/react-native-cli/index.js:249:3)
    at /usr/local/lib/node_modules/react-native-cli/index.js:217:7
    at /usr/local/lib/node_modules/react-native-cli/node_modules/prompt/lib/prompt.js:316:32
    at /usr/local/lib/node_modules/react-native-cli/node_modules/async/lib/async.js:142:25
    at assembler (/usr/local/lib/node_modules/react-native-cli/node_modules/prompt/lib/prompt.js:313:9)
    at /usr/local/lib/node_modules/react-native-cli/node_modules/prompt/lib/prompt.js:322:32
    at /usr/local/lib/node_modules/react-native-cli/node_modules/prompt/lib/prompt.js:597:5
  error: null,
  cmd: 'npm install --save --save-exact react-native',
  file: '/bin/sh',
  args: 
   [ '/bin/sh',
     '-c',
     'npm install --save --save-exact react-native' ],
  options: 
   { stdio: [ [Object], [Object], [Object] ],
     shell: true,
     file: '/bin/sh',
     args: 
      [ '/bin/sh',
        '-c',
        'npm install --save --save-exact react-native' ],
     envPairs: 
      [ 'TERM_PROGRAM=Apple_Terminal',
        'SHELL=/bin/bash',
        'TERM=xterm-256color',
        'TMPDIR=/var/folders/55/sqks2tv55flg67c1bbb2d9kh0000gn/T/',
        'Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.qiouajydN4/Render',
        'TERM_PROGRAM_VERSION=388',
        'OLDPWD=/Users/ketanmalhotra',
        'TERM_SESSION_ID=473A481F-186B-4E05-B4D4-7A319C0F4D9F',
        'USER=ketanmalhotra',
        'SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.rZIxxhyFU9/Listeners',
        '__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0',
        'PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin',
        'PWD=/Users/ketanmalhotra/Documents/Freelance/demo-react',
        'XPC_FLAGS=0x0',
        'XPC_SERVICE_NAME=0',
        'SHLVL=1',
        'HOME=/Users/ketanmalhotra',
        'LOGNAME=ketanmalhotra',
        'LC_CTYPE=UTF-8',
        'DISPLAY=/private/tmp/com.apple.launchd.3GdGOWMzei/org.macosforge.xquartz:0',
        '_=/usr/local/bin/react-native' ] },
  envPairs: 
   [ 'TERM_PROGRAM=Apple_Terminal',
     'SHELL=/bin/bash',
     'TERM=xterm-256color',
     'TMPDIR=/var/folders/55/sqks2tv55flg67c1bbb2d9kh0000gn/T/',
     'Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.qiouajydN4/Render',
     'TERM_PROGRAM_VERSION=388',
     'OLDPWD=/Users/ketanmalhotra',
     'TERM_SESSION_ID=473A481F-186B-4E05-B4D4-7A319C0F4D9F',
     'USER=ketanmalhotra',
     'SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.rZIxxhyFU9/Listeners',
     '__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0',
     'PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin',
     'PWD=/Users/ketanmalhotra/Documents/Freelance/demo-react',
     'XPC_FLAGS=0x0',
     'XPC_SERVICE_NAME=0',
     'SHLVL=1',
     'HOME=/Users/ketanmalhotra',
     'LOGNAME=ketanmalhotra',
     'LC_CTYPE=UTF-8',
     'DISPLAY=/private/tmp/com.apple.launchd.3GdGOWMzei/org.macosforge.xquartz:0',
     '_=/usr/local/bin/react-native' ],
  stderr: null,
  stdout: null,
  pid: 79752,
  output: [ null, null, null ],
  signal: null,
  status: 1 }
Command `npm install --save --save-exact react-native` failed.

I tried to find a solution to this problem but could not find anything that worked. Anyone got any idea how this can be fixed?

P.S. I'm doing this on a Mac (if that makes any difference)

1
  • It seems you've a problem with your network connection. Can you ping registry.npmjs.org? Have you tried to use another internet connection? Commented Sep 3, 2017 at 15:37

6 Answers 6

8

I checked for internet issues and also pinging registry.npmjs.org and everything was working fine. To fix the issue, I installed yarn using the following command:

brew install yarn

It seems to have fixed the issue. I'll just put this here if anyone faces the same problem while starting with react-native.

Sign up to request clarification or add additional context in comments.

2 Comments

I am just curious about why without yarn it doesn't work.
@TheRakeshPurohit - probably an issue related to one's internet connection. I think this is an alternative fix: stackoverflow.com/a/28818172/5115097
3
npm cache clean --force 
brew install yarn
npm install --save --save-exact react-native

or install yarn manually.

cd /opt
wget https://yarnpkg.com/latest.tar.gz
tar zvxf latest.tar.gz

then run

npm install --save --save-exact react-native

Comments

3
npm cache clean --force

Running this command first resolved the issue for me.

1 Comment

Can you provide any explanation for how this might work, or what it might do that would solve the problem in the question?
0

I solved the problem by, download and installed the yarn manually

use the command:

yarn config set "strict-ssl" false -g  
yarn add react-native --exact

Comments

0

npx react-native@latest init ProjectName --verison 0.74.5 --pm npm --install-pods false

Above command is working perfectly to create react native project

Comments

-1

if you running on windows, please disable the firewall.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.