Error Enoent when trying to deploy

this is my github repo, i’m trying to deploy a simple dockerfile to start vite on port 3000

but i am getting this error

2023-11-26T14:32:23.498 app[2865339fe20568] dfw [info] npm ERR! code ENOENT

2023-11-26T14:32:23.499 app[2865339fe20568] dfw [info] npm ERR! syscall open

2023-11-26T14:32:23.500 app[2865339fe20568] dfw [info] npm ERR! path /package.json

2023-11-26T14:32:23.500 app[2865339fe20568] dfw [info] npm ERR! errno -2

2023-11-26T14:32:23.502 app[2865339fe20568] dfw [info] npm ERR! enoent Could not read package.json: Error: ENOENT: no such file or directory, open ‘/package.json’

2023-11-26T14:32:23.502 app[2865339fe20568] dfw [info] npm ERR! enoent This is related to npm not being able to find a file.

2023-11-26T14:32:23.503 app[2865339fe20568] dfw [info] npm ERR! enoent

2023-11-26T14:32:23.504 app[2865339fe20568] dfw [info] npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2023-11-26T14_32_23_262Z-debug-0.log

Use an official Node runtime as a parent image

FROM node:14

Set the working directory in the container

WORKDIR /usr/src/app

Copy package.json and package-lock.json (or yarn.lock)

#COPY package.json ./

COPY ./package.json /usr/src/app/

RUN ls -la

Install project dependencies

RUN npm install

Bundle app source inside the Docker image

COPY . .

Build your app

RUN npm run build

Your app runs on port 3000, so expose this port

EXPOSE 3000

Define the command to run your app (adjust the start script according to your project)

CMD [“npm”, “run”, “start”]

This is my dockerfile

Note that there is a leading slash in this line. Something you are running is looking for package.json is the root directory of the file system.

The way I typically debug these types of situations is to run fly console which will launch an ephemeral machine and you will be logged in as root. From there you can look around, and run commands.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.