I am using docker-compose to install and start the app. But here node_modules are not available to application to run it. I have checked this Docker-compose: node_modules not present in a volume after npm install succeeds but it did not help me.
Here is my docker-compose.yml
version: "2"
services:
neo4j:
container_name: ms_neo4j
image: neo4j:latest
environment:
- NEO4J_AUTH=none
ports:
- "7474:7474"
- "7687:7687"
mongo:
container_name: ms_mongo
image: mongo:latest
ports:
- "27017:27017"
volumes:
- "./mongo/db:/data/db"
nginx:
build: ./nginx
container_name: ms_nginx
links:
- petstore
- users
ports:
- "80:80"
petstore:
build: ./petstore
container_name: ms_petstore
environment:
- loglevel=none
links:
- "mongo:mongo"
volumes:
- "./petstore:/src/app"
- node_modules:/petstore/node_modules
working_dir: "/src/app"
ports:
- "8080:8080"
- "5858:5858"
# command: npm run start
command: npm run start:dev
users:
build: ./users
container_name: ms_users
links:
- neo4j
volumes:
- "./users:/src/app"
- node_modules:/users/node_modules
working_dir: "/src/app"
command: npm start
volumes:
node_modules:
users/Dockerfile
FROM node:latest
RUN npm i -g rimraf typescript
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app/package.json
RUN npm install
COPY . /usr/src/app
petstore/Dockerfile
FROM node:latest
RUN npm i -g nodemon node-inspector@0.7.5 npm-run-all rimraf typescript
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app/package.json
RUN npm install
COPY . /usr/src/app
Getting these errors
src/config/Application.ts(4,25): error TS2307: Cannot find module 'config' or its corresponding type declarations.
src/config/Mongo.ts(1,33): error TS2307: Cannot find module 'mongodb' or its corresponding type declarations.
src/config/Mongo.ts(2,25): error TS2307: Cannot find module 'config' or its corresponding type declarations.
src/config/Mongo.ts(3,25): error TS2307: Cannot find module 'typedi' or its corresponding type declarations.
src/services/PetSwagger.ts(2,25): error TS2307: Cannot find module 'typedi' or its corresponding type declarations.
src/services/PetSwagger.ts(3,25): error TS2307: Cannot find module 'config' or its corresponding type declarations.
src/services/MongoService.ts(1,33): error TS2307: Cannot find module 'typedi' or its corresponding type declarations.
src/services/PetService.ts(1,33): error TS2307: Cannot find module 'typedi' or its corresponding type declarations.
src/controllers/PetStoreController.ts(1,40): error TS2307: Cannot find module 'routing-controllers' or its corresponding type declarations.
src/controllers/PetStoreController.ts(2,24): error TS2307: Cannot find module 'typedi' or its corresponding type declarations.
src/controllers/PetStoreController.ts(3,40): error TS2307: Cannot find module 'mongodb' or its corresponding type declarations.
src/subscribers/PetSubscriber.ts(1,37): error TS2307: Cannot find module 'event-dispatch' or its corresponding type declarations.
src/tasks/swagger.ts(2,21): error TS2307: Cannot find module 'fs' or its corresponding type declarations.
src/tasks/swagger.ts(3,23): error TS2307: Cannot find module 'glob' or its corresponding type declarations.
src/tasks/swagger.ts(7,38): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
Does anyone know how to resolve it ?