Your docker-compose.yml and Dockerfile setup for a React application looks mostly correct, but there are a few potential issues and improvements that might help resolve errors and improve the setup.
Hello,
Thank you so much for your reply.
You have removed the line /app/node_modules and this causes node_modules directory to be created on the host with root permissions which is causing the problem.
✓ Starting...
Error: EISDIR: illegal operation on a directory, open '/app/next-env.d.ts'
at async open (node:internal/fs/promises:634:25)
at async Object.writeFile (node:internal/fs/promises:1208:14)
at async writeAppTypeDeclarations (/app/node_modules/next/dist/lib/typescript/writeAppTypeDeclarations.js:59:5)
at async verifyTypeScriptSetup (/app/node_modules/next/dist/lib/verify-typescript-setup.js:124:9)
at async verifyTypeScript (/app/node_modules/next/dist/server/lib/router-utils/setup-dev-bundler.js:112:26)
at async startWatcher (/app/node_modules/next/dist/server/lib/router-utils/setup-dev-bundler.js:139:29)
at async setupDevBundler (/app/node_modules/next/dist/server/lib/router-utils/setup-dev-bundler.js:775:20)
at async Span.traceAsyncFn (/app/node_modules/next/dist/trace/trace.js:154:20)
at async initialize (/app/node_modules/next/dist/server/lib/router-server.js:80:30)
at async Server.<anonymous> (/app/node_modules/next/dist/server/lib/start-server.js:249:36) {
errno: -21,
code: 'EISDIR',
syscall: 'open',
path: '/app/next-env.d.ts'
}
I have come to the conclusion that Docker does not have a clear rule.