I have quite a strange error while runnning react-native start
:
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)
If I look at /home/augustin/Workspace/MyProject/node_modules/react-native/private-cli/src/server/server.js
, apparently, err
is undefined on:
如果我查看/home/augustin/Workspace/MyProject/node_modules/react-native/private-cli/src/server/server.js,显然,错误定义为:
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))
);
...
}
How can this be? Using:
怎么会这样?使用:
▶ node --version
v4.2.2
3 个解决方案
#1
#2
4
This error is shown because your watchman has watched too many files and crossed its limit. So there are two ways to solve it either use the watchman and cancel its limit or without using watchman, you can fix it by increasing the number of inotify watches using the below command on your terminal.
显示此错误是因为您的守望者已观看过多文件并超出其限制。因此,有两种方法可以解决它使用守望者并取消其限制或不使用守望者,你可以通过在终端上使用以下命令增加inotify手表的数量来解决它。
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
#3
1
I know this is an old issue, but real solution for this problem in my case was the one described in this * question As I was using docker to build an Android app, it turned out that unused space was running out on my drive. React Native uses node-js underneath, but it's not so obvious for the uninitiated.
我知道这是一个老问题,但在我的案例中这个问题的真正解决方案就是这个*问题中描述的问题因为我使用docker来构建一个Android应用程序,结果发现我的驱动器上没有使用的空间不足。 React Native在下面使用了node-js,但对于没有经验的人来说,它并不那么明显。
#1
6
I fixed the issue by installing watchman.
我通过安装watchman修复了这个问题。
Quoting this page:
引用此页面:
We recommend installing watchman, otherwise you might hit a node file watching bug.
我们建议安装watchman,否则你可能会看到节点文件看bug。
It is no recommendation, it is a dependency!
这不是推荐,而是依赖!
#2
4
This error is shown because your watchman has watched too many files and crossed its limit. So there are two ways to solve it either use the watchman and cancel its limit or without using watchman, you can fix it by increasing the number of inotify watches using the below command on your terminal.
显示此错误是因为您的守望者已观看过多文件并超出其限制。因此,有两种方法可以解决它使用守望者并取消其限制或不使用守望者,你可以通过在终端上使用以下命令增加inotify手表的数量来解决它。
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
#3
1
I know this is an old issue, but real solution for this problem in my case was the one described in this * question As I was using docker to build an Android app, it turned out that unused space was running out on my drive. React Native uses node-js underneath, but it's not so obvious for the uninitiated.
我知道这是一个老问题,但在我的案例中这个问题的真正解决方案就是这个*问题中描述的问题因为我使用docker来构建一个Android应用程序,结果发现我的驱动器上没有使用的空间不足。 React Native在下面使用了node-js,但对于没有经验的人来说,它并不那么明显。