当我的api在docker中运行(但在本地工作)时,找不到模块错误
第一次使用docker的用户。请帮帮忙!非常感谢!
我正在
server_1 | at Function.Module._resolveFilename (module.js:547:15)
server_1 | at Function.Module._load (module.js:474:25)
server_1 | at Module.require (module.js:596:17)
server_1 | at require (internal/module.js:11:18)
server_1 | at Object.<anonymous> (/api/src/workers/ContentWorker.js:3:17)
当我的api在docker中运行,但在我的本地环境中运行完美时。
我试图查看图像文件的结构,但是看起来不错。
这是我的dockerfile:
FROM mhart/alpine-node:8.11.4
WORKDIR /api
COPY package*.json /api/
RUN npm install
COPY server.js /api
COPY ./src /api/src
EXPOSE 5000
CMD ["node", "server.js"]
搬运工-撰写:
version: "3"
services:
server:
build: .
expose:
- 5000
environment:
- PORT=5000
- NODE_ENV=development
ports:
- 5000:5000
client:
build: ./client
environment:
- REACT_APP_PORT=3000
- CHOKIDAR_USEPOLLING=true
expose:
- 3000
ports:
- 3000:3000
links:
- server
文件结构:
回答如下: