I'm trying to run a node image inside docker but I have this error:
npm WARN saveError ENOENT: no such file or directory, open '/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/package.json'
npm WARN !invalid#2 No description
npm WARN !invalid#2 No repository field.
npm WARN !invalid#2 No README data
npm WARN !invalid#2 No license field.
Here is my docker file. I want to put all my project files in /home/app/ folder in the container:
# Use an official node runtime as a parent image
FROM node:10
# Set the working directory to /home/app
#WORKDIR /home/app/
# Bundle app source
COPY . /home/app/
# If you are building your code for production
# RUN npm install --only=production
RUN npm install
# Make port 8000 available to the world outside this container
EXPOSE 8000
CMD npm run dev
I'm on windows and I use hyper-V. My package.json is at the same level as my Dockerfile.
Any ideas?
Thanks
When npm install
command is run, the working directory is probably /
, and there is no package.json
here.
Just uncomment your line WORKDIR /home/app/
in your Dockerfile
.
My silly mistake was that I had forgotten to specify my WORKDIR
before attempting to run my npm commands... Hope this helps someone too!
Be sure to make sure your WORKDIR
is accurate for the CMD
line...
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