0

when docker run (npm ERR! path /package.json)

here is my Dockerfile

FROM node:8

WORKDIR /app
ENV NODE_ENV development

EXPOSE 3000

CMD ["npm", "start"]

app Dockerfile env.sh export-doc.sh mongo README.md redis

/app images log node_modules package.json package-lock.json src tsconfig.json

when i run the docker...

docker run -p 3000 --name server server:0.1. // I want to like 127.0.0.1/3000

error occurred (npm ERR! path /package.json)

how can i modify Dockerfile???

Bc Lee
  • 44
  • 1
  • 1
  • 9
  • You're not COPYing your application in. If you `docker run --rm -it server:0.1 sh` you'll get a shell on the image that just got built, and you should see it's basically empty. – David Maze Jun 05 '19 at 09:51

1 Answers1

1

As explained here https://nodejs.org/de/docs/guides/nodejs-docker-webapp/ try something like this:

FROM node:8

# Create app directory
WORKDIR /usr/src/app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./

RUN npm install
# If you are building your code for production
# RUN npm ci --only=production

# Bundle app source
COPY . .

EXPOSE 8080
CMD [ "npm", "start" ]
Ali
  • 1,982
  • 1
  • 15
  • 16