当我尝试在 Docker 容器上运行 NPM 时偶然发现了此错误。
FATAL EISDIR: illegal operation on a directory, read 19:05:13
at Object.readSync (node:fs:723:3)
at tryReadSync (node:fs:433:20)
at Object.readFileSync (node:fs:479:19)
at loadEnv (node_modules/@nuxt/config/dist/config.js:1152:78)
at Object.loadNuxtConfig (node_modules/@nuxt/config/dist/config.js:1070:15)
at loadNuxtConfig (node_modules/@nuxt/cli/dist/cli-index.js:338:32)
at NuxtCommand.getNuxtConfig (node_modules/@nuxt/cli/dist/cli-index.js:463:26)
at Object.run (node_modules/@nuxt/cli/dist/cli-start.js:115:30)
at NuxtCommand.run (node_modules/@nuxt/cli/dist/cli-index.js:413:22)
So in my case
npm install
worked just fine....when you try to run the app withnpm run start
your greeted with the above error.
最佳答案
它不是什么:
- 文件权限问题 - 以 root 身份运行命令
.npmrc
在同一目录或用户目录下发出
解决方案
将所有 python 虚拟环境文件夹添加到 .dockerignore
在我的例子中,我什至没有将虚拟环境文件夹复制到我的 docker 容器。它的存在是导致问题的原因。
示例
.dockerignore
/api/.env
这很奇怪,我不知道为什么会发生这种情况......但我花了几天时间试图弄清楚为什么我的构建可以在部署中工作但不能在本地工作 - python 虚拟环境在部署期间被忽略,所以它们在云构建期间从未出现过,这就是它起作用的原因。
以下是有关该问题的更多资源,但这些资源对我不起作用:
关于Docker 读取时出现 FATAL EISDIR : illegal operation on a directory, 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70478342/