Я установил express-validator
с npm install --save express-validator
в моем приложении узла, но я получаю следующую ошибку:
module.js:478
express-mongo | throw err;
express-mongo | ^
express-mongo |
express-mongo | Error: Cannot find module 'express-validator'
express-mongo | at Function.Module._resolveFilename (module.js:476:15)
express-mongo | at Function.Module._load (module.js:424:25)
express-mongo | at Module.require (module.js:504:17)
express-mongo | at require (internal/module.js:20:19)
express-mongo | at Object.<anonymous> (/app/validation/validator.js:1:98)
express-mongo | at Module._compile (module.js:577:32)
express-mongo | at Object.Module._extensions..js (module.js:586:10)
express-mongo | at Module.load (module.js:494:32)
express-mongo | at tryModuleLoad (module.js:453:12)
express-mongo | at Function.Module._load (module.js:445:3)
express-mongo | at Module.require (module.js:504:17)
express-mongo | at require (internal/module.js:20:19)
express-mongo | at Object.<anonymous> (/app/routes/user-geolocation.route.js:3:43)
express-mongo | at Module._compile (module.js:577:32)
express-mongo | at Object.Module._extensions..js (module.js:586:10)
express-mongo | at Module.load (module.js:494:32)
Это зависимости в моем package.json
:
"dependencies": {
"body-parser": "^1.19.0",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"express-mongo-crud": "^1.3.0",
"express-validator": "^6.2.0",
"mongodb": "^3.3.3",
"mongoose": "^5.7.7"
}
А это мой Dockerfile:
FROM node:boron
WORKDIR /app
COPY package*.json ./
RUN npm install
RUN npm install pm2 -g
COPY . .
EXPOSE 3000
CMD ["node", "app.js"]
В приложении мне просто нужно это так:
const { body, validationResult } = require('express-validator')
Это мой docker-composer.yml
файл:
version: '3'
services:
app:
build:
context: .
dockerfile: .docker/services/app/Dockerfile
container_name: express-mongo
restart: always
ports:
- "3000:3000"
volumes:
- .:/app
- /app/node_modules
links:
- db
depends_on:
- db
db:
container_name: mongo
image: mongo
ports:
- "27017:27017"
volumes:
- ./data:/data/db
Есть идеи о том, что может быть проблемой здесь?