简体   繁体   中英

sh: 1: nodemon: not found on Docker compose

I am having serious issues setting up docker. When I run sudo docker-compose up -d and sudo docker-compose logs -f my app is logging sh: 1: nodemon: not found over and over again. The problem is that I don't even have nodemon anymore: / If I run the exact same project with npm start and manually turn on mysql it works.

My dockerfile:

FROM node:latest

# Create app directory
WORKDIR ./

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./

#WORKDIR /node_modules
RUN npm ci --only=production
RUN npm install

# Bundle app source
COPY . .

EXPOSE 8003
CMD [ "npm", "start" ]

My package.json:

{
  "name": "name",
  "version": "6.4",
  "description": "sdasdsadsad",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node --inspect=0.0.0.0 app.js"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "axios": "^0.25.0",
    "bcryptjs": "^2.4.3",
    "body-parser": "^1.19.0",
    "compression": "^1.7.4",
    "connect-flash": "^0.1.1",
    "cookie-parser": "^1.4.5",
    "dotenv": "^10.0.0",
    "ejs": "^3.1.6",
    "express": "^4.17.1",
    "express-flash": "^0.0.2",
    "express-flash-messages": "^0.1.1",
    "express-formidable": "^1.2.0",
    "express-mysql-session": "^2.1.7",
    "express-session": "^1.17.2",
    "express-validator": "5.3.1",
    "helmet": "^4.6.0",
    "jsonwebtoken": "^8.5.1",
    "multer": "^1.4.3",
    "mysql": "^2.18.1",
    "mysql-pool-booster": "^1.0.3",
    "node-lame": "^1.3.2",
    "nodemailer": "^6.7.0",
    "sharp": "^0.29.1",
    "uglify-js": "^3.14.5",
    "uglifycss": "^0.0.29",
    "util.promisify": "^1.1.1"
  }
}

My docker-compose and package-lock.json also don't contain nodemon anymore...

Delete package lock file and Try using this command to rebuild the container.

sudo docker-compose up -d --build

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM