基本上我有一个主目录和书籍目录(一般文件结构,还有更多,但这些是重要的部分)。因此,当我从 main 向 booksServer 发出请求时,它不起作用,因为缺少节点模块。
这是因为节点模块位于特定路径的 docker 容器内: '/usr/src/app'
我怎样才能让 main.js 看到书籍(服务/容器)在这个特定路径中确实有正确的节点包?
我想我可以使用 docker-compose,但我想在没有 docker-compose 的情况下单独测试它。
**-Main Directory (Individual Service, has its own container)**
-Initiator (Fires commands)
-DockerFile
**-Books Directory (Individual Service, has its own container)**
-Stubs
-BooksStub.js (NEED THIS!, but it won't work because needs npm modules which is located in its container @/usr/src/app. How can I access the nodemodules that it's using?)
-booksServer.js
-Package*.json (lock and package.json)
-DockerFile
在 - 的里面
错误:
internal/modules/cjs/loader.js:800
throw err;
^
Error: Cannot find module 'grpc'
书籍 Dockerfile
FROM node:12.14.0
WORKDIR /usr/src/app
COPY package*.json ./
COPY . /usr/src/app
RUN npm install
EXPOSE 30043
CMD ["node", "booksServer.js"]
主 DockerFile
FROM node:12.14.0
WORKDIR /usr/src/app
COPY package*.json ./
COPY . /usr/src/app
RUN npm install
EXPOSE 4555
CMD ["node", "main.js"]