当我试图在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)
所以在我的情况下,
npm install
运行得很好。。。。当你试着跑步时npm run start
的应用程序出现上述错误。
它不是什么:
- 文件权限问题-以root身份运行命令
.npmrc
在同一目录或用户目录问题
解决方案
将您所有的python虚拟环境文件夹添加到.dockerignore
中——在我的情况下,我甚至没有将虚拟环境文件夹复制到我的docker容器中。它的存在导致了这个问题。
示例
.dokerignore
/api/.env
这很奇怪,我不知道为什么会发生这种事。。。但我花了好几天的时间试图弄清楚为什么我的构建在部署时有效,但在本地却不起作用——python虚拟环境在部署过程中被忽略了,所以它们在云构建过程中从未出现过,这就是它起作用的原因
这里有更多关于这个问题的资源,但这些对我不起作用:
- https://github.com/yarnpkg/yarn/issues/4336
- NPM在给出相同错误时卡住EISDIR:对目录的非法操作,出错时读取(本机(