• 【解决】Error: ENOSPC: no space left on device, watch


    发现问题:

    启动 node 项目ReactNative时候出现报错Error: ENOSPC: no space left on device, watch

    [root@iz2zeihk6kfcls5kwmqzj1z JFReactNativeProject]# npm start
    
    > wk_rn@0.0.1 start /app/jenkins_workspace/workspace/JFReactNativeProject
    > react-native start
    
    ┌──────────────────────────────────────────────────────────────────────────────┐
    │                                                                              │
    │  Running Metro Bundler on port 8081.                                         │
    │                                                                              │
    │  Keep Metro running while developing on any JS projects. Feel free to        │
    │  close this tab and run your own Metro instance if you prefer.               │
    │                                                                              │
    │  https://github.com/facebook/react-native                                    │
    │                                                                              │
    └──────────────────────────────────────────────────────────────────────────────┘
    
    Looking for JS files in
       /app/jenkins_workspace/workspace/JFReactNativeProject
    
    Loading dependency graph...fs.js:1413
        throw error;
        ^
    
    Error: ENOSPC: no space left on device, watch '/app/jenkins_workspace/workspace/JFReactNativeProject/node_modules/.staging/react-native-ddd311e5/ReactAndroid/src/androidTest/java/com/facebook/react/testing/idledetection'
        at FSWatcher.start (fs.js:1407:26)
        at Object.fs.watch (fs.js:1444:11)
        at NodeWatcher.watchdir (/app/jenkins_workspace/workspace/JFReactNativeProject/node_modules/_sane@4.1.0@sane/src/node_watcher.js:159:22)
        at Walker.<anonymous> (/app/jenkins_workspace/workspace/JFReactNativeProject/node_modules/_sane@4.1.0@sane/src/common.js:109:31)
        at Walker.emit (events.js:182:13)
        at /app/jenkins_workspace/workspace/JFReactNativeProject/node_modules/_walker@1.0.7@walker/lib/walker.js:69:16
        at go$readdir$cb (/app/jenkins_workspace/workspace/JFReactNativeProject/node_modules/_graceful-fs@4.2.2@graceful-fs/graceful-fs.js:187:14)
        at FSReqWrap.oncomplete (fs.js:169:20)
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! wk_rn@0.0.1 start: `react-native start`
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the wk_rn@0.0.1 start script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     /root/.npm/_logs/2019-09-25T06_57_58_754Z-debug.log
    
    

    解决办法:

    ENOSPC的含义是 Error No more hard-disk space available(没有更多的磁盘空间可以使用)

    首先使用df -hT发现磁盘空间还有很多

    然后从报错日志中发现FSWatcherObject.fs.watch字段,然后查看系统允许用户监听文件数相关内容

    #表示同一用户同时可以添加的watch数目(watch一般是针对目录,决定了同时同一用户可以监控的目录数量)
    [root@iz2zeihk6kfcls5kwmqzj1z JFReactNativeProject]# cat /proc/sys/fs/inotify/max_user_watches
    8192
    [root@iz2zeihk6kfcls5kwmqzj1z JFReactNativeProject]# echo 100000 > /proc/sys/fs/inotify/max_user_watches
    [root@iz2zeihk6kfcls5kwmqzj1z JFReactNativeProject]# cat /proc/sys/fs/inotify/max_user_watches
    100000
    

    永久生效方法如下:(建议采用此方法)

    vim /etc/sysctl.conf
    fs.inotify.max_user_watches = 100000(后面值根据实际情况可自行调整)
    添加并运行/sbin/sysctl -p即可 
    

    启动验证:

    再次启动,正常

    [root@iz2zeihk6kfcls5kwmqzj1z JFReactNativeProject]# npm start
    
    > wk_rn@0.0.1 start /app/jenkins_workspace/workspace/JFReactNativeProject
    > react-native start
    
    ┌──────────────────────────────────────────────────────────────────────────────┐
    │                                                                              │
    │  Running Metro Bundler on port 8081.                                         │
    │                                                                              │
    │  Keep Metro running while developing on any JS projects. Feel free to        │
    │  close this tab and run your own Metro instance if you prefer.               │
    │                                                                              │
    │  https://github.com/facebook/react-native                                    │
    │                                                                              │
    └──────────────────────────────────────────────────────────────────────────────┘
    
    Looking for JS files in
       /app/jenkins_workspace/workspace/JFReactNativeProject
    
    Loading dependency graph, done.
    

    知识点:

    inotify 的默认内核参数

    • /proc/sys/fs/inotify/max_queued_events 默认值: 16384 该文件中的值为调用inotify_init时分配给inotify instance中可排队的event的数目的最大值,超出这个值得事件被丢弃,但会触发IN_Q_OVERFLOW事件
    • /proc/sys/fs/inotify/max_user_instances 默认值: 128 指定了每一个real user ID可创建的inotify instatnces的数量上限
    • /proc/sys/fs/inotify/max_user_watches 默认值: 8192 指定了每个inotify instance相关联的watches的上限

    注意: max_queued_events 是 Inotify 管理的队列的最大长度,文件系统变化越频繁,这个值就应该越大
    如果你在日志中看到Event Queue Overflow,说明 max_queued_events 太小需要调整参数后再次使用.

  • 相关阅读:
    R语言实战(四)回归
    nginx无法启动: libpcre.so.1/libpcre.so.0: cannot open shared object file解决办法
    nginx无法启动: libpcre.so.1/libpcre.so.0: cannot open shared object file解决办法
    nginx无法启动: libpcre.so.1/libpcre.so.0: cannot open shared object file解决办法
    nginx无法启动: libpcre.so.1/libpcre.so.0: cannot open shared object file解决办法
    Debian安装fail2ban来防止扫描
    Debian安装fail2ban来防止扫描
    Debian安装fail2ban来防止扫描
    Debian安装fail2ban来防止扫描
    字典转Json
  • 原文地址:https://www.cnblogs.com/liyongjian5179/p/11584939.html
Copyright © 2020-2023  润新知