I am creating a docker image of a react-app and it return me an error that:
no such file or directory, open '/package.json'
Notice created a lockfile as package-lock.json. You should commit this file.
Here the Dockerfile
FROM node:alpine
RUN npm install
RUN npm run build
In your Docker file you need to specify the COPY execution to send to the container before execute copy the package.json, modified your Docker file to be like this:
FROM node:alpine
COPY package.json .
RUN npm install --no-package-lock
COPY . .
RUN npm run build
COPY package.json .
This command is to copy your package.json to the new container
RUN npm install --no-package-lock
This one is to install all of the dependencies of your project on the new container
COPY . .
This on is to move all your code to the new container
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With