Diferans ant `let`, `const` ak `var` an JavaScript
posée a month ago189 vuesht
Mwen wè kòd ak var, let ak const. Ki lè pou m sèvi ak chak youn? Èske gen yon rezon pou toujou evite var?
🤖 Diagnostic IA
Généré par IA. Ce n'est pas une réponse — la communauté ci-dessous le confirme ou le corrige. Vérifiez toujours avant de vous y fier.
2 réponses
Your CMD npm start runs in a shell that exits. Also you're missing EXPOSE and a proper working directory. Try:
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
CMD ["node", "server.js"]
Exec form (["node", ...]) keeps the process as PID 1.
Connectez-vous pour dire si ça a marché.
Rule of thumb: const by default, let when you must reassign, never var. var is function-scoped and hoisted, which causes subtle bugs. const doesn't make objects immutable — only the binding.
Connectez-vous pour dire si ça a marché.
Sign in and verify your email to post an answer.