开玩笑 - 观看抛出错误:eacces:root拥有的目录的权限
问题
当我运行jest -watch
时,即使我在目录中使用watchpathignorepatterns
目录:
Error: EACCES: permission denied, scandir '/path/to/repo/.pgdata'
.pgdata /
是用于PostgreSQL的Docker卷的目录。- 该目录由
root
拥有。
我尝试使用WatchPathignorePatterns
尝试的解决方案
在我的Jest Config:
watchPathIgnorePatterns: ['<rootDir>/\\.pgdata/'],
我尝试了modulepathignorepatterns
和tastpathignorepatterns
的类似模式。
我还尝试使用.pgdata
的所有者使用chown
将其设置为我的用户,但这需要更改Docker设置,我现在不想立即进行。
Problem
When I run jest --watch
, I get a permission denied error on a directory in my repository, even if I use watchPathIgnorePatterns
for the directory:
Error: EACCES: permission denied, scandir '/path/to/repo/.pgdata'
.pgdata/
is a directory used as a Docker volume for postgresql.- The directory is owned by
root
.
Solutions tried
I tried using watchPathIgnorePatterns
in my jest config:
watchPathIgnorePatterns: ['<rootDir>/\\.pgdata/'],
I tried a similar pattern for modulePathIgnorePatterns
and testPathIgnorePatterns
.
I also tried setting the owner of .pgdata
to my user with chown
, but that required a change in the Docker setup that I don't want to make right now.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 roots> roots 配置属性解决了问题:
这告诉jest jest jest仅在搜索文件
__测试__
目录。Note :我在
__测试__
中只有测试,而且我没有src/
目录。如果我这样做的话,它可能还必须包括在文档中的示例中, 。即使使用
WatchPathignorePatterns
,Jest Watcher仍然试图通过存储库中的所有目录运行。由于它遇到了一个目录,因此无法访问读取的目录,因此会引发错误(在Jest 28.1.0上测试)此无关发行评论为开玩笑暗示了解决方案。
Using the roots config property fixed the problem:
This tells jest to only search for files in the
__tests__
directory.Note: I only have tests in
__tests__
, and I don't have asrc/
directory. If I did, it would probably have to be included as well, as shown in the example in the documentation.Even when using
watchPathIgnorePatterns
, the jest watcher still tries to run through all directories in the repository. Since it encounters a directory it does not have access to read from, it throws the error (tested on jest 28.1.0)This unrelated issue comment for jest hinted at the solution.