Prettier 不会忽略具有 root 权限的文件夹
在我的项目中,我们有一个用于运行容器的 docker 文件夹。问题是,当我们运行 prettier 时,我收到此错误:
[error] Unable to expand directory: .
[error] EACCES: permission denied, scandir '/home/nanez/my-project/docker/data/postgres'
此文件夹需要 root 权限才能访问和删除它(使用 sudo ofc)。我已经将整个 docker 文件夹添加到 .prettierignore 以及特定的 postgres 文件夹中,但我仍然抛出错误。这是我的 .prettierignore
:
## Deps
node_modules
cache
generated
docker
./docker
/docker/**/*
/docker/*
/docker/data/postgres
如您所见,我添加了 docker 文件夹,其中包含我认为的所有可能性。
如果我使用负模式运行 prettier 效果很好,例如: npx prettier 。 '!./docker' --check
。这一切运行都没有问题,但我想知道为什么我不能直接忽略 npx prettier 。 --检查 .prettierignore
中是否已有 docker 文件夹。
我在 Ubuntu 20.04LTS 中使用 WSL2。
谢谢 :)
In my project we have a docker folder that we use to run the container. The issue is that when we run prettier i got this error:
[error] Unable to expand directory: .
[error] EACCES: permission denied, scandir '/home/nanez/my-project/docker/data/postgres'
This folder need root permissions to access and delete it (using sudo ofc). I already added the whole docker folder to .prettierignore
and also the specific postgres folder and i still throwing the error. Here my .prettierignore
:
## Deps
node_modules
cache
generated
docker
./docker
/docker/**/*
/docker/*
/docker/data/postgres
As you can see, I added the docker folder with all the posibilities that I thought.
If I run prettier with the negative pattern work good, for ex: npx prettier . '!./docker' --check
. This run all without problem, but I'm wonder why I can't ignore directly with npx prettier . --check
if already I have the docker folder in the .prettierignore
.
I'm using WSL2 with Ubuntu 20.04LTS.
Thanks :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如 @Sagnik Pradhan 评论,目前(2023 年 3 月)在 Prettier 中打开问题 #11568。
从那里,有只有一个评论解决办法
因此,目前问题中已经建议了最佳答案(并且对我有用):
As @Sagnik Pradhan comments, this is currently (March 2023) an open issue #11568 in Prettier.
From there, there is only a commented work around
So currently the best answer has already been suggested in the question (and worked for me):