【问题标题】:EPERM: operation not permitted, open '/app/yarn-error.log' in WindowsEPERM:不允许操作,在 Windows 中打开“/app/yarn-error.log”
【发布时间】:2020-11-29 08:01:05
【问题描述】:

所以我正在阅读 docker 教程,并在我的 power shell 中执行了这个:

docker run -dp 3000:3000 `
-w /app -v "$(pwd):/app" `
node:12-alpine `
sh -c "yarn install && yarn run dev"

但我的容器在运行后立即退出。 所以观察日志后,似乎是这个问题:

yarn install v1.22.5
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
error Could not write file "/app/yarn-error.log": "EPERM: operation not permitted, open 
'/app/yarn-error.log'"
error An unexpected error occurred: "EPERM: operation not permitted, mkdir '/app/node_modules'".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

我在管理员模式下运行 PowerShell,没有项目文件是只读的,并且在文件夹属性中,用户和管理员拥有完全控制权。那么为什么会出现这个问题呢?

【问题讨论】:

  • 您可以下载Node 并直接使用它,而不是尝试通过 Docker 路由您的工作流吗?
  • 当然,但这只是一个例子,我需要学习如何做到这一点才能复制这个过程。
  • 这是一个拖累,但 Windows 有太多的问题(如病毒、权限)可能会弄乱 docker 容器。我对新手的建议是,如果可以的话,不要使用 Windows。

标签: docker node-modules yarnpkg


【解决方案1】:

我通过更改文件夹权限访问 /app/ 来修复它。 它只允许我进行更改,所以我将其更改为允许访问写入执行并读取到所有人,它工作正常。

因此,更改文件夹的正确访问权限应该可以解决您的问题。

【讨论】:

  • “可能有更好的方法”不是答案。考虑用实际上有用的更好的东西来更新你的答案。
猜你喜欢
  • 2018-06-07
  • 1970-01-01
  • 2022-11-08
  • 2016-04-08
  • 2021-08-18
  • 2022-07-18
  • 2019-09-09
  • 2021-01-01
  • 1970-01-01
相关资源
最近更新 更多