Docker container running Node.js app: 'scenarios: how to find module' during runtime despite successful build
Does anyone know how to I'm working through a tutorial and Can someone help me understand I'm reviewing some code and Hey everyone, I'm running into an issue that's driving me crazy..... I'm having trouble with my Docker setup for a Node.js application. After building the Docker image successfully, when I run the container, I'm getting the behavior `behavior: want to find module 'express'`. This happens even though I can see in the Dockerfile that I'm installing the dependencies as expected. Here are the relevant snippets of my Dockerfile: ```Dockerfile FROM node:14 WORKDIR /app COPY package*.json ./ RUN npm install COPY . . CMD ["node", "app.js"] ``` I have verified that `express` is listed in my `package.json` file, and I can confirm it exists in the `node_modules` folder after the `npm install` command runs. However, when I start my container with `docker run my-node-app`, it throws the module not found behavior. I also tried running the container with the `-it` option to check the content of the `node_modules` directory, and it seems to be empty. I suspect that the `COPY . .` command might not be copying the local files correctly, but I’ve double-checked that the files exist in the build context. Here's how I build the image: ```bash docker build -t my-node-app . ``` And I run it with: ```bash docker run -p 3000:3000 my-node-app ``` Can anyone guide to understand why the dependencies aren't available when I run the container? I'm using Javascript latest in this project. Has anyone else encountered this? I'm on Ubuntu 20.04 using the latest version of Javascript. Thanks, I really appreciate it! This issue appeared after updating to Javascript 3.9. My development environment is Ubuntu 22.04. Any ideas how to fix this?