美文网首页还在路上React NativeRN资料
React Native初始化项目时候报错?react-nati

React Native初始化项目时候报错?react-nati

作者: jay_den | 来源:发表于2017-03-14 21:53 被阅读3877次

    之前初始化都没问题的,有一次初始化发现报错说网络有问题,然后再初始化就报下面的错误:

    This will walk you through creating a new React Native project in /Users/dengjiewen/Desktop/joke
    Using yarn v0.20.3
    Installing react-native...
    yarn add v0.20.3
    info No lockfile found.
    [1/4] 🔍  Resolving packages...
    error An unexpected error occurred: "https://registry.yarnpkg.com/react-native: read ETIMEDOUT".
    info If you think this is a bug, please open a bug report with the information provided in "/Users/dengjiewen/Desktop/joke/yarn-error.log".
    info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
    { Error: Command failed: yarn add react-native --exact
        at checkExecSyncError (child_process.js:490:13)
        at execSync (child_process.js:530: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 init (/usr/local/lib/node_modules/react-native-cli/index.js:200:5)
        at Object.<anonymous> (/usr/local/lib/node_modules/react-native-cli/index.js:153:7)
        at Module._compile (module.js:571:32)
        at Object.Module._extensions..js (module.js:580:10)
        at Module.load (module.js:488:32)
        at tryModuleLoad (module.js:447:12)
      error: null,
      cmd: 'yarn add react-native --exact',
      file: '/bin/sh',
      args: [ '/bin/sh', '-c', 'yarn add react-native --exact' ],
      options: 
       { stdio: [ [Object], [Object], [Object] ],
         shell: true,
         file: '/bin/sh',
         args: [ '/bin/sh', '-c', 'yarn add react-native --exact' ],
         envPairs: 
          [ 'TERM_PROGRAM=Apple_Terminal',
            'ANDROID_HOME=/Users/dengjiewen/Library/Android/sdk',
            'SHELL=/bin/bash',
            'TERM=xterm-256color',
            'TMPDIR=/var/folders/t4/k953mqjj7b71xjmdr0bx_nz40000gn/T/',
            'Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.jeiwp8RAEI/Render',
            'TERM_PROGRAM_VERSION=377',
            'OLDPWD=/Users/dengjiewen',
            'TERM_SESSION_ID=BED38688-46DE-42D7-AC7B-D522572F3D5A',
            'USER=dengjiewen',
            'SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.AMMxRnfsSb/Listeners',
            '__CF_USER_TEXT_ENCODING=0x1F5:0x19:0x34',
            'PATH=/Library/Java/JavaVirtualMachines/jdk1.8.0_121-b13.jdk/Contents/Home/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:.:/Users/dengjiewen/Library/Android/sdk/tools:/Users/dengjiewen/Library/Android/sdk/platform-tools',
            'PWD=/Users/dengjiewen/Desktop',
            'JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home',
            'LANG=zh_CN.UTF-8',
            'XPC_FLAGS=0x0',
            'XPC_SERVICE_NAME=0',
            'SHLVL=1',
            'HOME=/Users/dengjiewen',
            'LOGNAME=dengjiewen',
            'CLASSPATH=JAVA_HOME/lib/tools.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_121-b13.jdk/Contents/Home/lib/dt.jar:.',
            '_=/usr/local/bin/react-native' ] },
      envPairs: 
       [ 'TERM_PROGRAM=Apple_Terminal',
         'ANDROID_HOME=/Users/dengjiewen/Library/Android/sdk',
         'SHELL=/bin/bash',
         'TERM=xterm-256color',
         'TMPDIR=/var/folders/t4/k953mqjj7b71xjmdr0bx_nz40000gn/T/',
         'Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.jeiwp8RAEI/Render',
         'TERM_PROGRAM_VERSION=377',
         'OLDPWD=/Users/dengjiewen',
         'TERM_SESSION_ID=BED38688-46DE-42D7-AC7B-D522572F3D5A',
         'USER=dengjiewen',
         'SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.AMMxRnfsSb/Listeners',
         '__CF_USER_TEXT_ENCODING=0x1F5:0x19:0x34',
         'PATH=/Library/Java/JavaVirtualMachines/jdk1.8.0_121-b13.jdk/Contents/Home/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:.:/Users/dengjiewen/Library/Android/sdk/tools:/Users/dengjiewen/Library/Android/sdk/platform-tools',
         'PWD=/Users/dengjiewen/Desktop',
         'JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home',
         'LANG=zh_CN.UTF-8',
         'XPC_FLAGS=0x0',
         'XPC_SERVICE_NAME=0',
         'SHLVL=1',
         'HOME=/Users/dengjiewen',
         'LOGNAME=dengjiewen',
         'CLASSPATH=JAVA_HOME/lib/tools.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_121-b13.jdk/Contents/Home/lib/dt.jar:.',
         '_=/usr/local/bin/react-native' ],
      stderr: null,
      stdout: null,
      pid: 495,
      output: [ null, null, null ],
      signal: null,
      status: 1 }
    Command `yarn add react-native --exact` failed.
    

    出现这个问题,可以试一下执行下面二行代码

    npm config set registry https://registry.npm.taobao.org
    npm config set disturl https://npm.taobao.org/dist
    
    

    然后再执行一下初始化就可以了。

    相关文章

      网友评论

      本文标题:React Native初始化项目时候报错?react-nati

      本文链接:https://www.haomeiwen.com/subject/kclknttx.html