运行react-native启动时出错

runnning 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在undefined上是:

  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 

我通过安装看守来解决这个问题。

引用此页面 :

我们build议安装守望者,否则你可能会打一个节点文件看bug。

这是没有build议,这一个依赖!

我知道这是一个老问题,但在我的情况下,这个问题的真正解决scheme是在这个Stackoverflow问题中描述的一个因为我使用docker来build立一个Android应用程序,事实certificate,未使用的空间用完了我的驱动器。 React Native使用下面的node-js,但对于外行来说并不那么明显。

显示这个错误是因为你的守望者观看了太多的文件并超过了限制。 所以有两种方法可以解决它,要么使用看守,取消其限制或不使用守望,你可以通过在terminal上使用下面的命令增加inotify守护数量来解决它。

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