初始化项目时候报错?react-native init



  • sudo react-native init sapp
    Password:
    This will walk you through creating a new React Native project in /Users/dark/Documents/work/sapp
    Using yarn v0.20.3
    Installing react-native...
    yarn add v0.20.3
    info No lockfile found.
    [1/4] 🔍 Resolving packages...
    warning There appears to be trouble with your network connection. Retrying...
    warning react-native > xcode > node-uuid@1.4.7: use uuid module instead
    error Received malformed response from registry for undefined. The registry may be down.
    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:
    [ 'SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.sZmHUSONNf/Listeners',
    'COLORFGBG=7;0',
    'LANG=zh_CN.UTF-8',
    'PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/dark/Documents/java/maven-3.2.3/bin:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin:/Users/dark/.rvm/bin:/usr/local/Cellar/mongodb/3.2.0/bin',
    'DISPLAY=/private/tmp/com.apple.launchd.i9Hbc6IGQ1/org.macosforge.xquartz:0',
    'TERM=xterm-256color',
    'HOME=/Users/dark',
    '__CF_USER_TEXT_ENCODING=0x0:25:52',
    'LC_CTYPE=zh_CN.UTF-8',
    'LSCOLORS=Gxfxcxdxbxegedabagacad',
    'MAIL=/var/mail/root',
    'LOGNAME=root',
    'USER=root',
    'USERNAME=root',
    'SHELL=/bin/sh',
    'SUDO_COMMAND=/usr/local/bin/react-native init sapp',
    'SUDO_USER=dark',
    'SUDO_UID=501',
    'SUDO_GID=20' ] },
    envPairs:
    [ 'SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.sZmHUSONNf/Listeners',
    'COLORFGBG=7;0',
    'LANG=zh_CN.UTF-8',
    'PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/dark/Documents/java/maven-3.2.3/bin:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin:/Users/dark/.rvm/bin:/usr/local/Cellar/mongodb/3.2.0/bin',
    'DISPLAY=/private/tmp/com.apple.launchd.i9Hbc6IGQ1/org.macosforge.xquartz:0',
    'TERM=xterm-256color',
    'HOME=/Users/dark',
    '__CF_USER_TEXT_ENCODING=0x0:25:52',
    'LC_CTYPE=zh_CN.UTF-8',
    'LSCOLORS=Gxfxcxdxbxegedabagacad',
    'MAIL=/var/mail/root',
    'LOGNAME=root',
    'USER=root',
    'USERNAME=root',
    'SHELL=/bin/sh',
    'SUDO_COMMAND=/usr/local/bin/react-native init sapp',
    'SUDO_USER=dark',
    'SUDO_UID=501',
    'SUDO_GID=20' ],
    stderr: null,
    stdout: null,
    pid: 7395,
    output: [ null, null, null ],
    signal: null,
    status: 1 }
    Command yarn add react-native --exact failed.

    报错,这如何解决???什么情况。。。代理没问题。网络没问题。



  • 这个问题貌似没有人知道啊?


  • administrators

    @darksc 说:

    error Received malformed response from registry for undefined. The registry may be down.

    要么没设置镜像源(registry)地址,导致被墙
    要么源地址设置有误



  • @sunnylqm 说:

    @darksc 说:

    error Received malformed response from registry for undefined. The registry may be down.

    要么没设置镜像源(registry)地址,导致被墙
    要么源地址设置有误

    关键我开着代理呢,哥们。。。


  • administrators

    @darksc 我说了两个可能性



  • 进入 cd /usr/local/bin 找到yarn 把它删掉 rm yarn 再执行这句 react-native init Hello



  • @ChangeXL -,- 干掉yarn了啊。。。目测我这是网络问题。



  • @ChangeXL 我这边干掉yarn 就行了,O(∩_∩)O谢谢!


登录后回复