javascript - docker - 错误:找不到模块'winston'
问题描述
背景
我正在使用 EC2 实例来创建 docker 容器。
问题
当我运行时docker-compose up -d --build
,所有容器都成功启动。
但是当我运行docker logs <container id>
容器test-web
时,会显示错误。
Error: Cannot find module 'winston'
我所做的
我已经在本地环境中尝试过相同的命令,但它运行成功,所以我想知道这是一个 docker 问题。
我也尝试 sh 到图像,但该winston
模块存在于 node_modules 中。
Dockerfile
FROM node:lts-alpine
RUN npm install --global sequelize-cli nodemon
WORKDIR /server
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3030
CMD ["npm", "run", "dev"]
码头工人-compose.yml
version: '2.1'
services:
test-db:
image: mysql:5.7
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=true
- MYSQL_USER=admin
- MYSQL_PASSWORD=12345
- MYSQL_DATABASE=test
volumes:
- ./db-data:/var/lib/mysql
ports:
- 3306:3306
test-web:
environment:
- NODE_ENV=local
#- DEBUG=*
- PORT=3030
build: .
command: >
./wait-for-db-redis.sh test-db npm run dev
volumes:
- ./:/server
ports:
- "3030:3030"
depends_on:
- test-db
.dockerignore
node_modules
npm-debug.log
包.json
{
"name": "docker-server",
"description": "",
"version": "0.0.0",
"homepage": "",
"private": true,
"main": "src",
"keywords": [
"feathers"
],
"author": {
"name": "hello",
"email": "hello@example.com"
},
"contributors": [],
"bugs": {},
"directories": {
"lib": "src",
"test": "test/",
"config": "config/"
},
"engines": {
"node": "^13.0.0",
"npm": ">= 3.0.0"
},
"scripts": {
"test": "npm run lint && npm run mocha",
"lint": "eslint src/. test/. --config .eslintrc.json --fix",
"dev": "nodemon --legacy-watch src/",
"start": "node src/",
},
"standard": {
"env": [
"mocha"
],
"ignore": []
},
"dependencies": {
"@feathersjs/authentication": "^4.5.11",
"@feathersjs/authentication-local": "^4.5.11",
"@feathersjs/authentication-oauth": "^4.5.11",
"@feathersjs/configuration": "^4.5.11",
"@feathersjs/errors": "^4.5.11",
"@feathersjs/express": "^4.5.11",
"@feathersjs/feathers": "^4.5.11",
"@feathersjs/socketio": "^4.5.11",
"@feathersjs/transport-commons": "^4.5.11",
"aws-sdk": "^2.868.0",
"compression": "^1.7.4",
"cors": "^2.8.5",
"express-winston": "^4.1.0",
"feathers-hooks-common": "^5.0.5",
"feathers-logger": "^0.3.2",
"feathers-permissions": "^2.1.4",
"feathers-sequelize": "^6.2.0",
"helmet": "^4.4.1",
"sequelize": "^6.5.1",
"serve-favicon": "^2.5.0",
"uuid": "^3.4.0",
"winston": "^3.3.3",
"winston-dynamodb": "^0.3.1"
},
"devDependencies": {
"axios": "^0.21.1",
"eslint": "^7.22.0",
"mocha": "^8.3.2",
"nodemon": "^2.0.7"
}
}
解决方案
推荐阅读
- javascript - 单击时在 div 内水平滚动(带按钮)
- python - 如果条件满足,则将项目添加到列表中,直到该列表达到一定长度(Python)
- php - 一个字符串响应中的 Ajax 多个文件名
- angular - 发送带有角度查询参数的帖子时出错
- docker - 无人机 CI - docker 插件 - 解析错误。为什么无人机无法解析?
- ffmpeg - FFMPEG 图像序列正常并反转为单个视频
- arduino - Mega R3 WiFi:ESP8266 模块代码中串行通信的初始化问题
- css - 页面加载时可变字体闪烁
- javascript - react-native-fs 库没有移动或复制文件 - 奇怪的结果
- vba - VBA:使用数组公式