Docker错误:没有这样的文件或目录,请打开'/package.json' [英] Docker error: no such file or directory, open '/package.json'
本文介绍了Docker错误:没有这样的文件或目录,请打开'/package.json'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在docker内部运行节点图像,但出现此错误:
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.
这是我的docker文件.我想将所有项目文件放在容器的/home/app/文件夹中:
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
我在Windows上,并且使用hyper-V.我的package.json与我的Dockerfile处于同一级别.
I'm on windows and I use hyper-V. My package.json is at the same level as my Dockerfile.
有什么想法吗?
谢谢
推荐答案
运行 npm install
命令时,工作目录可能是/
,并且没有 package.json
在这里.
When npm install
command is run, the working directory is probably /
, and there is no package.json
here.
只需在 Dockerfile
中取消对 WORKDIR/home/app/
行的注释.
Just uncomment your line WORKDIR /home/app/
in your Dockerfile
.
这篇关于Docker错误:没有这样的文件或目录,请打开'/package.json'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文