![](/img/trans.png)
[英]React Native - error running “npm start” and “react-native run-android”
[英]Error while running 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)
如果我查看/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
顯示此錯誤是因為您的守望者已觀看太多文件並超過其限制。 因此有兩種方法可以解決它使用守望者並取消其限制或不使用守望者,您可以通過在終端上使用以下命令增加inotify手表的數量來解決它。
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
我知道這是一個老問題,但在我的案例中這個問題的真正解決方案就是這個Stackoverflow問題中描述的問題因為我使用docker來構建Android應用程序,結果發現我的驅動器上沒有使用的空間不足。 React Native在下面使用了node-js,但是對於那些不熟悉的人來說並不是那么明顯。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.