Jest: 错误:Linux 上的监视模式会导致 ENOSPC Node.js 错误

创建于 2017-04-04  ·  77评论  ·  资料来源: facebook/jest

版本:

  • 纱线:v0.21.3
  • 节点:v6.9.2
  • npm:3.10.9
  • Ubuntu:16.10

安装使用yarn global add jest (在chown处有~/.config/yarn/global/node_modules/

命令失败: jest -c lib/tools/testing/jest.config.json --no-cache --watch

如果我运行jest -c lib/tools/testing/jest.config.json --no-cache测试工作 100% 罚款。

错误信息:

fs.js:1431
    throw error;
    ^

Error: watch /home/fooBar/dev/blah/lib/tools/testing/node_modules/core-js/modules ENOSPC
    at exports._errnoException (util.js:1022:11)
    at FSWatcher.start (fs.js:1429:19)
    at Object.fs.watch (fs.js:1456:11)
    at NodeWatcher.watchdir (/home/fooBar/.config/yarn/global/node_modules/sane/src/node_watcher.js:148:20)
    at Walker.<anonymous> (/home/fooBar/.config/yarn/global/node_modules/sane/src/node_watcher.js:361:12)
    at emitTwo (events.js:106:13)
    at Walker.emit (events.js:191:7)
    at /home/fooBar/.config/yarn/global/node_modules/walker/lib/walker.js:69:16
    at go$readdir$cb (/home/fooBar/.config/yarn/global/node_modules/graceful-fs/graceful-fs.js:149:14)
    at FSReqWrap.oncomplete (fs.js:123:15)

Tmp 目录: yarn config set tmp /tmp/

磁盘可用空间: df -h / (已使用 11%)

Jest 配置:lib/tools/testing/jest.config.json

{
    "clearMocks": true,
    "bail": true,
    "transform": {
        ".(ts|tsx)": "<rootDir>/lib/tools/testing/node_modules/ts-jest/preprocessor.js"
    },
    "testResultsProcessor": "<rootDir>/lib/tools/testing/node_modules/ts-jest/coverageprocessor.js",
    "testMatch": [
        "**/__tests__/*.(ts|tsx|js)"
    ],
    "moduleFileExtensions": [
        "ts",
        "tsx",
        "js"
    ],
    "moduleDirectories": [
        "node_modules",
        "<rootDir>/lib/tools/testing/node_modules"
    ],
    "collectCoverage": true,
    "coverageDirectory": "./reports/",
    "coverageReporters": [
        "clover",
        "lcov",
        "text-summary"
    ],
    "coverageThreshold": {
        "global": {
            "branches": 50,
            "functions": 80,
            "lines": 60
        }
    },
    "collectCoverageFrom": [
        "{src,lib}/**/*.{ts,js}",
        "!lib/{tools}/**/*",
        "!**/{node_modules,vendor}/**"
    ]
}

最有用的评论

根据我的发现,它与 Jest 完全无关。 在 Linux(或 Mac)上,我们可以在 IO 级别放置最大数量的系统观察器(根据我的理解)。 因此,对于大型项目,Jest 似乎正试图查看许多文件。

修理:

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

来源: Node.JS 错误:ENOSPC

所有77条评论

这意味着您的驱动器上没有空间。 请清理您的磁盘。

@cpojer不确定您是否阅读了该问题,但是;

磁盘可用空间:df -h /(已使用 11%)

在那里提到 - 磁盘空间虽然被报告为问题,但实际上不是问题。

颠簸@cpojer

我有同样的问题,而且肯定有可用磁盘空间

不幸的是,我们没有资源在 Linux 上调试它。 如果您有时间,并且可以查看并帮助我们提出拉取请求来修复它,我们将不胜感激。

@cpojer我会看看 - 但我也相信它不仅限于 Linux 操作系统。 无论如何,你介意重新打开这个问题吗?

根据我的发现,它与 Jest 完全无关。 在 Linux(或 Mac)上,我们可以在 IO 级别放置最大数量的系统观察器(根据我的理解)。 因此,对于大型项目,Jest 似乎正试图查看许多文件。

修理:

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

来源: Node.JS 错误:ENOSPC

感谢您的调查,如果您安装了watchman,它应该可以工作。

刚刚从 Windows 7 切换到 Ubuntu 16.04.2 LTS,Jest 在 Windows 中运行良好,但由于上述相同原因未能在 Linux 下运行。 如果您添加--watch标志,它似乎只会失败。

首先,我接受了@cpojer 的建议并按照文档安装了守望者,然后再次运行了jest --watch ,我得到了以下错误:

jest --watch

events.js:163
      throw er; // Unhandled 'error' event
      ^

Error: A non-recoverable condition has triggered.  Watchman needs your help!
The triggering condition was at timestamp=1493335106: inotify-add-watch(/home/username/project_name/node_modules/browser-resolve/node_modules/resolve/example) -> The user limit on the total number of inotify watches was reached; increase the fs.inotify.max_user_watches sysctl
All requests will continue to fail with this message until you resolve
the underlying problem.  You will find more information on fixing this at
https://facebook.github.io/watchman/docs/troubleshooting.html#poison-inotify-add-watch

    at ChildProcess.<anonymous> (/home/username/project_name/node_modules/sane/node_modules/fb-watchman/index.js:207:21)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:194:7)
    at maybeClose (internal/child_process.js:899:16)
    at Socket.<anonymous> (internal/child_process.js:342:11)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:191:7)
    at Pipe._handle.close [as _onclose] (net.js:510:12)
npm ERR! Test failed.  See above for more details.

这很有用,因为它告诉你该怎么做,所以我然后使用了@maraisr的修复程序,jest 现在正在 Ubuntu 上工作:tada::beers:

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

感谢您解决这个问题@maraisr @cpojer :+1: 您认为应该向Jest 网站添加一些内容吗?

谢谢兄弟@maraisr

@maraisr你知道该解决方案是否有 sudo-less 版本吗?

@vspedr不确定 - 我可以看看!

但是我们正在接触那里的系统文件,因此为了安全起见,您需要提升权限。 如果你能让自己成为一个 sudoer,我相信你可以在没有 sudo 的情况下运行这些命令。

但是,是的 - 我会看看,看看我能想出什么。

可能是我遗漏了什么……但是为什么 jest 需要查看我的node_modules目录中的任何内容?
我该如何配置它才能跳过node_modules

@SimenB ,正如我看到的 watchPathIgnorePatterns 仅在 watch 本身启动并运行后才跳过文件,这就是为什么 watch 的启动可能需要很长时间,有时会抛出 ENOSPC

喔好吧。 在设置观察者时尊重watchPathIgnorePatterns PR 会很好:)

@SimenB能否请您指出源代码中直接开始观看的位置? 我很难找到这个地方

发现观察者正在使用 HasteMap 作为所有应该观察的文件的来源,以及现在正在构建 HasteMap 的问题。
HasteMap 尊重 modulePathIgnorePatterns 选项,但根据文档中的描述使用此选项是不合逻辑的:

在模块加载器将这些路径视为“可见”之前,与所有模块路径匹配的正则表达式模式字符串数组。 如果给定模块的路径与任何模式匹配,则它在测试环境中将不支持 require()。

我对吗?

@maraisr

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

此解决方案在我的 mac os 10.13.4 上不起作用,它返回以下错误

sysctl: illegal option -- p usage: sysctl [-bdehiNnoqx] name[=value] ... sysctl [-bdehNnoqx] -a sysctl: illegal option -- p usage: sysctl [-bdehiNnoqx] name[=value] ... sysctl [-bdehNnoqx] -a

我不明白为什么这个错误是“关闭的”。 强迫用户使用sudo来完成一项平凡的任务当然是一个错误。

这是 Jest 独有的错误:mocha、guard 等都监视特定的 _subdirectories_,而不是. ,以避免这个问题。 (子目录列表可以是可选的。)

在玩笑 21 中,我从未遇到过这个问题。 vscode 正在与 jest 竞争观看文件。 当我关闭 vscode 时,jest 开始正常工作。

当我打开两个 VSCode 实例时,我遇到了这个问题。

请重新打开或将修复添加到故障排除以进行测试。

这花了我很长时间才找到并最终修复。 我开始一次又一次地做变通方法。 谢谢@samit4me

我打开了 2 个 VSCode 实例,这是完全有道理的。

要摆脱这个错误,只需使用 sublime/atom/gedit。 或者您可以在构建/调试时关闭 VSCode。

lsof | wc -l
可以阐明问题的根源。
任何程序,无论是浏览器还是内置 Web 引擎(即 VS 代码),都会显着增加打开的文件描述符的数量(每个程序大约 30 000 个甚至更多)。
我没有看到可靠的解决方法,因为。 网络技术变得无处不在

为这一点的正确方向干杯。 我在 watch 失败时遇到了同样的问题,但在这种情况下,只有一个 VSCode 实例在运行。 关闭它,然后运行我的项目并重新打开,解决了它。

IMO, node_modules上应该有手表是不可接受的

它主要是来自 Web 引擎的工作(和一堆已删除的)文件,而不是来自 node_modules 的文件,它阻止了观察者的空闲节点。

更新项目依赖项时出现此错误。 为了解决我刚刚删除并安装了node_modules

非常感谢你

@maraisr太好了, echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p在 Ubuntu 18.04.1 LTS 上为我工作

@maraisr谢谢你像@xameeramir说的那样在 ubuntu 18 上完美修复

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p也为我修复了它:+1:

请注意,升级时通常会覆盖/etc/sysctl.conf (例如,从 Ubuntu 16 到 18 LTS)并将删除更高的限制。 我被警告过这一点,但在其他类似警告的海洋中很容易错过。 尽管我_看到了max_user_watches差异,但今天早上我第一次遇到错误时仍然被抛出一个循环,因为这些东西之间的联系并不明显。 然而,一旦我登陆这个问题页面,我就很清楚我需要修复什么。

万岁,重新解决了我两年前解决的问题 :laughing:

关于fs.inotify.max_user_watches=524288有趣事情
就我而言,该项目似乎足够大,以至于524288还不够大。 所以......好吧fs.inotify.max_user_watches=2048000帮助。
可能也和旁边的vs code里面开很多东西有关。

当我在未受影响的处女 create-react-app 上运行“npm start”时,在 ubuntu 18.10 上得到这个
成功了!!!
解决方案
echo fs.inotify.max_user_watches=2048000 | 须藤 tee -a /etc/sysctl.conf && 须藤 sysctl -p

它的价值:也许它与环境有关(模块 X 与模块 Y)。

我有 2 个具有 2 种不同配置的 ReactNative 应用程序。 主要是因为其中一个使用尚未准备好用于最新 RN 版本的 React-Native-Camera(即:最新的 Gradle 和此类环境)。 另一个是测试最新RN版本和环境的演示。

使用 React-Native-Camera 的应用程序在Linux上可以完美编译 (--variant=release)。 另一个得到了ENOSPC错误。 “fs.inotify.max_user_watches”修复确实有效。 我就像“嗯?”。 正如其他人所描述的,我在 NAS 上有大量的千兆字节......

这是两个应用程序的“package.json”。

也许你会发现一些有用的东西。
应用程序 1(相机):

{
  "name": "********************",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "i18n-js": "^3.0.11",
    "react": "16.4.1",
    "react-native": "0.56.0",
    "react-native-camera": "^1.2.0",
    "react-native-languages": "^3.0.1",
    "react-navigation": "^2.16.0"
  },
  "devDependencies": {
    "babel-jest": "23.4.2",
    "babel-preset-react-native": "5.0.2",
    "jest": "23.5.0",
    "react-test-renderer": "16.4.1"
  },
  "jest": {
    "preset": "react-native"
  }
}

应用2(测试演示):

{
  "name": "DemoReactNative",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "i18n-js": "^3.0.11",
    "react": "16.6.0-alpha.8af6728",
    "react-native": "0.57.3",
    "react-native-languages": "^3.0.1",
    "react-navigation": "^2.18.0"
  },
  "devDependencies": {
    "babel-jest": "23.6.0",
    "jest": "23.6.0",
    "metro-react-native-babel-preset": "0.48.1",
    "react-test-renderer": "16.6.0-alpha.8af6728"
  },
  "jest": {
    "preset": "react-native"
  }
}

沼泽,
感谢作品!!!

只是运行 sudo 为我工作

@ 4E71-NOP 我看到了同样的事情。 一旦我们从 RN 0.51 更新到 0.57,我们就开始遇到这个问题。 增加inotify限制有帮助

我用 sudo 运行......它对我有用

echo fs.inotify.max_user_watches=524288 | 须藤 tee -a /etc/sysctl.conf && 须藤 sysctl -p
这对 UBUNTU 18.10 有帮助

非常感谢。 但正如@adamhooper之前提到的, Forcing the user to sudo for a mundane task is certainly a bug.

对普通用户有什么想法吗?

echo fs.inotify.max_user_watches=524288 |

根据我的发现,它与 Jest 完全无关。 在 Linux(或 Mac)上,我们可以在 IO 级别放置最大数量的系统观察器(根据我的理解)。 因此,对于大型项目,Jest 似乎正试图查看许多文件。

修理:

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

来源: Node.JS 错误:ENOSPC

完美解决了我的问题,非常感谢!

我使用modulePathIgnorePatterns设置修复了它,不包括node_modules

将此添加到您的 package.json 中:

  "jest": {
    "modulePathIgnorePatterns": [
      "node_modules"
    ]
  }

像魅力一样工作。 谢谢@maraisr

[hayesmaker64<strong i="5">@gohan</strong> hype-layer]$ npm test

> [email protected] test /home/hayesmaker64/Workspace/twitch/hype-layer
> react-scripts test

internal/fs/watchers.js:173
    throw error;
    ^

Error: ENOSPC: System limit for number of file watchers reached, watch '/home/hayesmaker64/Workspace/twitch/hype-layer/node_modules/get-stream'
    at FSWatcher.start (internal/fs/watchers.js:165:26)
    at Object.watch (fs.js:1254:11)
    at NodeWatcher.watchdir (/home/hayesmaker64/Workspace/twitch/hype-layer/node_modules/sane/src/node_watcher.js:175:20)
    at Walker.<anonymous> (/home/hayesmaker64/Workspace/twitch/hype-layer/node_modules/sane/src/common.js:116:12)
    at Walker.emit (events.js:182:13)
    at /home/hayesmaker64/Workspace/twitch/hype-layer/node_modules/walker/lib/walker.js:69:16
    at go$readdir$cb (/home/hayesmaker64/Workspace/twitch/hype-layer/node_modules/graceful-fs/graceful-fs.js:162:14)
    at FSReqWrap.oncomplete (fs.js:141:20)
npm ERR! Test failed.  See above for more details.
[hayesmaker64<strong i="6">@gohan</strong> hype-layer]$ ^C
[hayesmaker64<strong i="7">@gohan</strong> hype-layer]$ ^C
[hayesmaker64<strong i="8">@gohan</strong> hype-layer]$ npm test

> [email protected] test /home/hayesmaker64/Workspace/twitch/hype-layer
> react-scripts test


Out of the box, Create React App only supports overriding these Jest options:

  • collectCoverageFrom
  • coverageReporters
  • coverageThreshold
  • globalSetup
  • globalTeardown
  • resetMocks
  • resetModules
  • snapshotSerializers
  • watchPathIgnorePatterns.

These options in your package.json Jest configuration are not currently supported by Create React App:

  • modulePathIgnorePatterns

If you wish to override other Jest options, you need to eject from the default setup. You can do so by running npm run eject but remember that this is a one-way operation. You may also file an issue with Create React App to discuss supporting more options out of the box.

对于未来的访问者, @pomber的解决方案客观上比增加观看限制要好得多:

将此添加到您的 package.json 中:

  "jest": {
    "modulePathIgnorePatterns": [
      "node_modules"
    ]
  }

根据我的发现,它与 Jest 完全无关。 在 Linux(或 Mac)上,我们可以在 IO 级别放置最大数量的系统观察器(根据我的理解)。 因此,对于大型项目,Jest 似乎正试图查看许多文件。

修理:

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

来源: Node.JS 错误:ENOSPC

这解决了我在运行npm run serve时遇到的 Vue 问题感谢您的建议 @maraisr

@pomber谢谢,它在不增加任何系统限制的情况下解决了我在 Fedora 上的问题。

谢谢@maraisr ,它解决了我的问题:)

非常感谢! @maraisr

你的解决方案对我有用,@maraisr!
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
谢谢!

对于任何感兴趣的人来说,这是我的错误:
您的项目的日志将显示在下方。 按 Ctrl+C 退出。
(节点:19425)未处理的PromiseRejectionWarning:错误:ENOSPC:达到文件观察者数量的系统限制,观察'/home/claire/Documents/my-app-name'
在 FSWatcher.start (internal/fs/watchers.js:165:26)
在 Object.watch (fs.js:1274:11)
在 NodeWatcher.watchdir (/home/claire/Documents/my-app-name/node_modules/sane/src/node_watcher.js:175:20)
在新的 NodeWatcher (/home/claire/Documents/my-app-name/node_modules/sane/src/node_watcher.js:45:8)
在 createWatcher (/home/claire/Documents/my-app-name/node_modules/jest-haste-map/build/index.js:780:23)
在 Array.map ()
在 HasteMap._watch (/home/claire/Documents/my-app-name/node_modules/jest-haste-map/build/index.js:936:44)
在 _buildPromise._buildFileMap.then.then.hasteMap (/home/claire/Documents/my-app-name/node_modules/jest-haste-map/build/index.js:355:23)
在 processTicksAndRejections (internal/process/next_tick.js:81:5)
(节点:19425)UnhandledPromiseRejectionWarning:未处理的承诺拒绝。 这个错误要么是因为在没有 catch 块的情况下抛出了异步函数,要么是因为拒绝了一个没有用 .catch() 处理过的承诺。 (拒绝编号:1)
(节点:19425)[DEP0018] 弃用警告:不推荐使用未处理的承诺拒绝。 将来,未处理的承诺拒绝将使用非零退出代码终止 Node.js 进程。
ENOSPC:达到文件观察者数量的系统限制,观察“/home/claire/Documents/my-app-name”
ENOSPC:达到文件观察者数量的系统限制,观察“/home/claire/Documents/my-app-name”

我使用modulePathIgnorePatterns设置修复了它,不包括node_modules

将此添加到您的 package.json 中:

  "jest": {
    "modulePathIgnorePatterns": [
      "node_modules"
    ]
  }

之后,只需删除node_modules文件夹并再次运行npm install

"modulePathIgnorePatterns": [
      "node_modules"
    ]

这是真正的答案

如果您一直遇到这个问题并且不能忽略node_modules ,安装 Watchman 会有所帮助:
https://facebook.github.io/watchman/

Jest 中有 Watchman 特定的优化,因此它还可以显着缩短大型项目的启动时间。

展望未来,当这样做会导致此类错误时,我将研究不自动监视node_modules (例如:没有 Watchman 并且不在 Darwin 上,因此不能使用fsevents )。

哦嘿@scotthovestadt! 希望你一切都好!

对于未来的访问者, @pomber的解决方案客观上比增加观看限制要好得多:

将此添加到您的 package.json 中:

  "jest": {
    "modulePathIgnorePatterns": [
      "node_modules"
    ]
  }

这应该是最佳答案。 人们 - 请碰这个。 为什么你会简单地说“哦,内存/资源不足 - 给它更多的内存/资源”而不检查原因?

不幸的是,我们没有资源在 Linux 上调试它。 如果您有时间,并且可以查看并帮助我们提出拉取请求来修复它,我们将不胜感激。

Linux 是所有专业开发者的事实上的标准,你真的更关心 Windows 和 Mac 用户吗? 那是耻辱

@maraisr谢谢。 我解决了问题。 :舞蹈家:

对于未来的访问者, @pomber的解决方案客观上比增加观看限制要好得多:

将此添加到您的 package.json 中:

  "jest": {
    "modulePathIgnorePatterns": [
      "node_modules"
    ]
  }

这应该是最佳答案。 人们 - 请碰这个。 为什么你会简单地说“哦,内存/资源不足 - 给它更多的内存/资源”而不检查原因?

只是记录一下:目前的正确修复直到 #7585 修复 #7544 才起作用。

可能有一些权限问题试试 Sudo npm start

此命令将增加允许的观察者数量:
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
来源

根据我的发现,它与 Jest 完全无关。 在 Linux(或 Mac)上,我们可以在 IO 级别放置最大数量的系统观察器(根据我的理解)。 因此,对于大型项目,Jest 似乎正试图查看许多文件。

修理:

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

来源: Node.JS 错误:ENOSPC

@maraisr谢谢,您的解决方案在 Ubuntu 18.04 上运行良好

根据我的发现,它与 Jest 完全无关。 在 Linux(或 Mac)上,我们可以在 IO 级别放置最大数量的系统观察器(根据我的理解)。 因此,对于大型项目,Jest 似乎正试图查看许多文件。

修理:

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

来源: Node.JS 错误:ENOSPC

谢谢,这解决了我的问题。

未来的访客和@sunnykeshri @JimmyBastos @BrotherDonkey @CodeMonkeyG ,为了我的理智,请停止传播观看限制修复。

对于未来的访问者, @pomber的解决方案客观上比增加观看限制要好得多:

将此添加到您的 package.json 中:

  "jest": {
    "modulePathIgnorePatterns": [
      "node_modules"
    ]
  }

这应该是最佳答案。 人们 - 请碰这个。 为什么你会简单地说“哦,内存/资源不足 - 给它更多的内存/资源”而不检查原因?

未来的访客和@sunnykeshri @JimmyBastos @BrotherDonkey @CodeMonkeyG ,为了我的理智,请停止传播观看限制修复。

对于未来的访问者, @pomber的解决方案客观上比增加观看限制要好得多:

将此添加到您的 package.json 中:

  "jest": {
    "modulePathIgnorePatterns": [
      "node_modules"
    ]
  }

这应该是最佳答案。 人们 - 请碰这个。 为什么你会简单地说“哦,内存/资源不足 - 给它更多的内存/资源”而不检查原因?

Create React App 限制了可以在包 jest config 中使用的键 - 有没有人找到在 CRA 应用程序中解决这个问题的方法?

根据我的发现,它与 Jest 完全无关。 在 Linux(或 Mac)上,我们可以在 IO 级别放置最大数量的系统观察器(根据我的理解)。 因此,对于大型项目,Jest 似乎正试图查看许多文件。

修理:

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

来源: Node.JS 错误:ENOSPC

感谢 resovel o problema já tava procurando a horas o queera esse rro

根据我的发现,它与 Jest 完全无关。 在 Linux(或 Mac)上,我们可以在 IO 级别放置最大数量的系统观察器(根据我的理解)。 因此,对于大型项目,Jest 似乎正试图查看许多文件。

修理:

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

来源: Node.JS 错误:ENOSPC

只是一个改进的说明,您最好指导用户检查标志/值不存在,这样他们就不会得到它的重复实例。 考虑到这一点,或者使用某种工具。

根据我的发现,它与 Jest 完全无关。 在 Linux(或 Mac)上,我们可以在 IO 级别放置最大数量的系统观察器(根据我的理解)。 因此,对于大型项目,Jest 似乎正试图查看许多文件。

修理:

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

来源: Node.JS 错误:ENOSPC

谢谢你的最佳答案。

根据我的发现,它与 Jest 完全无关。 在 Linux(或 Mac)上,我们可以在 IO 级别放置最大数量的系统观察器(根据我的理解)。 因此,对于大型项目,Jest 似乎正试图查看许多文件。

修理:

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

来源: Node.JS 错误:ENOSPC

谢谢你的回答
这对我有用

谢谢@maraisr

由于最近的几条评论一直在建议较早的解决方法,而后来的修复开始被埋没,我觉得有必要为未来的读者(和@pradeepsrawat029 @karsa87 @igorgoiis )重申,如果适用,这最初是不可能的,因为一个笑话错误:

对于未来的访问者, @pomber的解决方案客观上比增加观看限制要好得多:

将此添加到您的 package.json 中:

  "jest": {
    "modulePathIgnorePatterns": [
      "node_modules"
    ]
  }

这应该是最佳答案。 人们 - 请碰这个。 为什么你会简单地说“哦,内存/资源不足 - 给它更多的内存/资源”而不检查原因?

我能够用sudo react-native start解决这个问题

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

pfftdammitchris picture pfftdammitchris  ·  76评论

TYRONEMICHAEL picture TYRONEMICHAEL  ·  80评论

paularmstrong picture paularmstrong  ·  66评论

bookman25 picture bookman25  ·  79评论

SimenB picture SimenB  ·  131评论