Reputation: 35
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
Upvotes: 3
Views: 956
Reputation: 68
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
Upvotes: 3