【问题标题】:Error while running react-native start运行 react-native start 时出错
【发布时间】:2016-03-02 03:16:20
【问题描述】:

我在运行react-native start时遇到了一个很奇怪的错误:

 ERROR  watch /home/augustin/Workspace/MyProject ENOSPC
{"code":"ENOSPC","errno":"ENOSPC","syscall":"watch /home/augustin/Workspace/MyProject","filename":"/home/augustin/Workspace/MyProject"}
Error: watch /home/augustin/Workspace/MyProject ENOSPC
    at exports._errnoException (util.js:874:11)
    at FSWatcher.start (fs.js:1234:19)
    at Object.fs.watch (fs.js:1262:11)
    at NodeWatcher.watchdir (/home/augustin/Workspace/MyProject/node_modules/react-native/node_modules/sane/src/node_watcher.js:144:20)
    at new NodeWatcher (/home/augustin/Workspace/MyProject/node_modules/react-native/node_modules/sane/src/node_watcher.js:45:8)
    at /home/augustin/Workspace/MyProject/node_modules/react-native/packager/react-packager/src/FileWatcher/index.js:95:21
    at tryCallOne (/home/augustin/Workspace/MyProject/node_modules/react-native/node_modules/promise/lib/core.js:37:12)
    at /home/augustin/Workspace/MyProject/node_modules/react-native/node_modules/promise/lib/core.js:103:15
    at flush (/home/augustin/Workspace/MyProject/node_modules/react-native/node_modules/promise/node_modules/asap/raw.js:50:29)
    at doNTCallback0 (node.js:419:9)

See http://facebook.github.io/react-native/docs/troubleshooting.html
for common problems and solutions.
/home/augustin/Workspace/MyProject/node_modules/react-native/private-cli/src/server/server.js:91
    if (error.code === 'EADDRINUSE') {
             ^

TypeError: Cannot read property 'code' of undefined
    at process.<anonymous> (/home/augustin/Workspace/MyProject/node_modules/react-native/private-cli/src/server/server.js:105:14)
    at emitOne (events.js:77:13)
    at process.emit (events.js:169:7)
    at process._fatalException (node.js:223:26)

如果我查看/home/augustin/Workspace/MyProject/node_modules/react-native/private-cli/src/server/server.js,显然err 未定义:

  process.on('uncaughtException', error => {
    if (error.code === 'EADDRINUSE') {
      console.log(
        chalk.bgRed.bold(' ERROR '),
        chalk.red('Packager can\'t listen on port', chalk.bold(args.port))
      );
    ...
  }

这怎么可能?使用:

▶ node --version
v4.2.2

【问题讨论】:

    标签: node.js react-native


    【解决方案1】:

    我通过安装 watchman 解决了这个问题。

    引用this page:

    我们建议安装 watchman,否则您可能会遇到节点文件监视错误。

    不是推荐,它依赖!

    【讨论】:

    • 我试图修复(来自this ppa),但它抱怨 fs.inotify.max_user_watches 太低。解决这个问题使其工作,但这似乎与@yaronius 描述的问题相同,并且与 ENOSPC 有关(我猜是空间不足来发出通知)。
    【解决方案2】:

    显示此错误是因为您的守望者查看了太多文件并超出了限制。所以有两种方法可以解决它,要么使用 watchman 并取消其限制,要么不使用 watchman,您可以通过在终端上使用以下命令增加 inotify 手表的数量来解决它。

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

    【讨论】:

      【解决方案3】:

      我知道这是一个老问题,但就我而言,这个问题的真正解决方案是Stackoverflow question 中描述的解决方案 当我使用 docker 构建 Android 应用程序时,结果发现我的驱动器上未使用的空间快用完了。 React Native 底层使用的是 node-js,但是对于外行来说并不是那么明显。

      【讨论】:

        猜你喜欢
        • 2019-06-10
        • 2022-01-03
        • 1970-01-01
        • 2018-05-20
        • 2021-09-13
        • 1970-01-01
        相关资源
        最近更新 更多