我正在学习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


当前回答

在Linux上,我实际上是用sudo运行的。 Sudo 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,那么您的项目将达到系统文件监视器的限制

要解决这个问题,请在您的终端上尝试:

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

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

当我在Ubuntu机器上使用Visual Studio Code时,有时会遇到这个问题。

在我的情况下,下面的解决方法会有所帮助:

停止监视器,关闭Visual Studio Code,启动监视器,然后再次打开Visual Studio Code。

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

我的非恶魔命令:

Nodemon server.js通过NPM启动