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)
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.
npm cache clean --force
Running this command first resolved the issue for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With