错误:使用Expo构建Android应用程序时套接字挂起

时间:2018-01-31 18:38:47

标签: android json react-native npm expo

运行exp build:android后,cmd输出:

[exp] Making sure project is set up correctly...
[exp] Your project looks good!
[exp] Checking if current build exists...

[exp] No currently active or previous builds for this project.

? Would you like to upload a keystore or have us generate one for you?
If you don't know what this means, let us handle it! :)
 false
[exp] Unable to find an existing exp instance for this directory, starting a new one...
[exp] Starting React Native packager...
[exp] Scanning folders for symlinks in C:\Users\Ansis\Desktop\Pašapmācība\Test\node_modules (39ms)
[exp] Loading dependency graph.
[exp] Tunnel connected.
[exp] Publishing...
[exp] Dependency graph loaded.
[exp] Building iOS bundle
[exp] Error: socket hang up
[exp] Set EXPO_DEBUG=true in your env to view the stack trace.

几乎没有人遇到过这个错误,并且已经通过添加

修复了这个错误
"packagerOpts": {
      "nonPersistent": true,
}

到app.json。嗯...对我来说什么都没改变。如果我能看到更详细的输出,也许我会理解在哪里看,但我甚至不了解Set EXPO_DEBUG=true in your env的含义。

这是app.json:

 {
   "expo": {
    "name": "Vards",
    "icon": "android.png",
    "version": "1.0.0",
    "slug": "vards",
    "sdkVersion": "25.0.0",
    "ios": {
      "bundleIdentifier": "com.kojas.vards"
    },
    "android": {
      "package": "com.kojas.vards"
    },
    "packagerOpts": {
      "nonPersistent": true,
    }
   }
 }

和package.json:

{
  "name": "Test",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "jest-expo": "25.0.0",
    "react-native-scripts": "1.11.1",
    "react-test-renderer": "16.2.0"
  },
  "main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
  "scripts": {
    "start": "react-native-scripts start",
    "eject": "react-native-scripts eject",
    "android": "react-native-scripts android",
    "ios": "react-native-scripts ios",
    "test": "node node_modules/jest/bin/jest.js"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "expo": "^25.0.0",
    "react": "16.2.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-25.0.0.tar.gz"
  }
}

exp start运行正常。 npm start也是如此。 感谢。

编辑: 这是将EXPO_DEBUG设置为true后的输出:

[exp] Dependency graph loaded.
[exp] Warning: Not using the Expo fork of react-native. See https://docs.expo.io/.
[exp] Building iOS bundle
[exp] Error: socket hang up
[exp] RequestError: Error: socket hang up
    at new RequestError (C:\Users\Ansis\AppData\Roaming\npm\node_modules\exp\node_modules\request-promise-core\lib\errors.js:14:15)
    at Request.plumbing.callback (C:\Users\Ansis\AppData\Roaming\npm\node_modules\exp\node_modules\request-promise-core\lib\plumbing.js:87:29)
    at Request.RP$callback [as _callback] (C:\Users\Ansis\AppData\Roaming\npm\node_modules\exp\node_modules\request-promise-core\lib\plumbing.js:46:31)
    at self.callback (C:\Users\Ansis\AppData\Roaming\npm\node_modules\exp\node_modules\request\request.js:186:22)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at Request.onRequestError (C:\Users\Ansis\AppData\Roaming\npm\node_modules\exp\node_modules\request\request.js:878:8)
    at emitOne (events.js:116:13)
    at ClientRequest.emit (events.js:211:7)
    at Socket.socketOnEnd (_http_client.js:423:9)
    at emitNone (events.js:111:20)
    at Socket.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1055:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)

3 个答案:

答案 0 :(得分:0)

要获取更详细的错误消息,请在运行exp命令时设置env var(即)EXPO_DEBUG=true exp start

答案 1 :(得分:0)

我已解决问题。 事实证明,崩溃是由项目所在目录名称中的unicode字符引起的。

更改此内容
C:\Users\Ansis\Desktop\Pašapmācība\Test\node_modules

对此
C:\Users\Ansis\Desktop\Prog\Test\node_modules
修复它。

答案 2 :(得分:0)

tl; dr:

尝试以下操作:echo 'fs.inotify.max_user_watches=524288' | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

长版

好的,所以我们暂停了该问题的迭代……我们的错误是相似的,但是还报告了ENOSPC错误代码,对于解决该问题至关重要。通过在发布之前运行此行来解决此问题:

echo 'fs.inotify.max_user_watches=524288' | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

inotifywatchman(由Facebook制造的文件监视程序)使用的系统,而watchman被Expo所使用。对于Travis来说,我们将达到手表的极限,并报告我们没有足够的空间,但实际上我们只用完了文件描述符。上面的行增加了该数量。 More here。您也可以尝试安装watchman,但这在Ubuntu上似乎很难完成,并且上面的命令对我们有用,所以无论如何。

在我们的特定情况下,我们使用的是默认的Travis构建,事实证明该构建可在Ubuntu 14上运行。它与上面的命令并不特别相似,因此我们切换到使用Ubuntu 16(Xenial)并必须启用{{ 1}}模式。因此,对于Travis员工来说,以下是我们sudo文件中的重要细节:

.travis.yml

我们还注意到,在将dist: xenial # We needed to specify PostgreSQL 10 once we switched to Ubuntu 16 # you might need this as well addons: postgresql: "10" # then add the script however you want 与命令一起使用时,它会阻塞,因此我们将其分为两个单独的操作:

&&

希望这对其他人有帮助!