我正在学习GraphQL,并且在GraphQL操作中使用棱镜绑定。当我启动我的Node.js服务器时,我面临这个nodemon错误,它给了我一个由graphql-cli自动生成的模式文件的路径。这个错误是关于什么的?

错误:

Internal watch failed: ENOSPC: System limit for number of file watchers reached, watch '/media/ rehans -sattar/Development/All projects/GrpahQl/graph-ql-course/graphql-prisma/src/generated


当前回答

我认为这里给出的大多数答案都是正确的,但是使用systemctl命令重新启动我的服务解决了我的问题。检查下面的命令:

sudo systemctl restart systemd-sysctl.service

其他回答

这是Linux内核中inotify (inode notify)的问题,可以通过下面的命令来解决:

对于临时解决方案,直到重新启动pc,使用以下命令 Sudo sysctl -w fs.inotify.max_user_watches=100000 一个永久的解决方案:为了使这个问题永久存在,添加一个名为/etc/sysctl.d/10-user-watch .conf的文件,包含以下内容: fs.inotify。Max_user_watches = 10000

在进行更改之后,使用sudo sysctl -p重新加载/etc目录下所有sysctl配置文件中的设置。

我认为这里给出的大多数答案都是正确的,但是使用systemctl命令重新启动我的服务解决了我的问题。检查下面的命令:

sudo systemctl restart systemd-sysctl.service

在我的例子中,当我在Linux服务器上执行nodemon命令时,我打开了Visual Studio Code (SSH到服务器)。所以根据Juri Sinitson的回答,我只是关闭Visual Studio Code并再次运行nodemon命令。这很有效。

我的非恶魔命令:

Nodemon server.js通过NPM启动

很难知道要增加多少观众。所以,这里有一个实用程序来加倍的观察者的数量:

function get_inode_watcher_count() {
  find /proc/*/fd -user "$USER" -lname anon_inode:inotify -printf '%hinfo/%f\n' 2>/dev/null | 
  xargs cat | 
  grep -c '^inotify'
}

function set_inode_watchers() {
  sudo sysctl -w fs.inotify.max_user_watches="$1"
}

function double_inode_watchers() {
  watcher_count="$(get_inode_watcher_count)"
  set_inode_watchers "$((watcher_count * 2))"

  if test "$1" = "-p" || test "$1" = "--persist"; then
    echo "fs.inotify.max_user_watches = $((watcher_count * 2))" > /etc/sysctl.d/10-user-watches.conf
  fi
}

# Usage
double_inode_watchers
# to make the change persistent
double_inode_watchers --persist

在Linux上,我实际上是用sudo运行的。 Sudo NPM启动