【发布时间】:2019-01-19 12:49:30
【问题描述】:
我正在尝试在 docker 中运行节点映像,但出现此错误:
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/ 文件夹中:
# 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 处于同一级别。
有什么想法吗?
谢谢
【问题讨论】:
-
对于遇到此问题的其他人,请确保您没有使用 docker-compose 卷覆盖目录
标签: node.js docker package.json