![](/img/trans.png)
[英]npm ENOENT: no such file or directory, open '/usr/app/package.json'. While trying to share local space with docker using docker-compose
[英]get “npm ERR! enoent: no such file or directory” when mapping a volume in docker-compose
我有一个docker-compose文件,其中包含我的应用的自定义图片和官方的mongo图片。 只要我不尝试为我的应用程序映射卷,它就可以正常工作,而我正在尝试创建开发docker-compose文件。 我觉得我的docker-compose.dev.yml文件中的音量设置有误。 我尝试过以其他方式设置音量,但总是会出错。 我不确定如何映射该卷,以便我对代码所做的任何更改都将在容器中更改
以下是我的docker-compose.dev.yml文件,我的应用程序的Dockerfile和我的package.json文件。 我还将包括我看到的错误
感谢您提供的任何帮助
泊坞窗,compose.dev.yml
version: "3"
services:
app:
container_name: database
restart: always
build: .
volumes:
- ./:/usr/src/app
ports:
- "8080:8080"
links:
- mongo
mongo:
container_name: mongo
image: mongo:4
ports:
- "27017:27017"
Dockerfile
FROM node:10
# Create app directory
WORKDIR /usr/src/app
# Install app dependencies
COPY package*.json ./
RUN npm install
# Bundle app source into container
COPY . .
EXPOSE 8080
CMD [ "npm", "start" ]
的package.json
{
"name": "database",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"cookie-parser": "~1.4.3",
"debug": "~2.6.9",
"express": "~4.16.0",
"http-errors": "~1.6.2",
"morgan": "~1.9.0",
"pug": "2.0.0-beta11"
}
}
错误即时通讯...
WARNING: Image for service app was built because it did not already exist.
To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating mongo ... done
Creating database ... done
Attaching to mongo, database
database | npm ERR! path /usr/src/app/package.json
database | npm ERR! code ENOENT
database | npm ERR! errno -2
database | npm ERR! syscall open
database | npm ERR! enoent ENOENT: no such file or directory, open
'/usr/src/app/package.json'
database | npm ERR! enoent This is related to npm not being able to find a file.
database | npm ERR! enoent
database |
database | npm ERR! A complete log of this run can be found in:
database | npm ERR! /root/.npm/_logs/2019-01-11T17_20_49_720Z-debug.log
我的docker-compose.dev.yml中的卷有误
我有
- ./:/usr/src/app
它必须是
- .:/usr/src/app
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.