Docker Community Forums

Share and learn in the Docker community.

[resolved] Docker Compose Keeps running old package.json/Dockerfile


I am trying to run a project which requires both nodejs and mysql. I used to have start script like "start": "nodemon app.js"

I changed it to "start": "node app.js"

But I still get error which says nodemon is not available.

updials-auth | 
updials-auth | > updials-auth@0.0.1 start /srv
updials-auth | > nodemon app.js
updials-auth | 
updials-auth | sh: 1: nodemon: not found
updials-auth | npm ERR! code ELIFECYCLE
updials-auth | npm ERR! syscall spawn
updials-auth | npm ERR! file sh
updials-auth | npm ERR! errno ENOENT
updials-auth | npm ERR! updials-auth@0.0.1 start: `nodemon app.js`
updials-auth | npm ERR! spawn ENOENT
updials-auth | npm ERR! 
updials-auth | npm ERR! Failed at the updials-auth@0.0.1 start script.
updials-auth | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
updials-auth | 
updials-auth | npm ERR! A complete log of this run can be found in:
updials-auth | npm ERR!     /root/.npm/_logs/2020-03-29T12_06_59_465Z-debug.log

Here is my dockerFile

FROM node:12.14.0

#USER node

WORKDIR /var/www

COPY . .

COPY package.json /usr/share/app

#COPY package.lock.json /usr/share/app


RUN npm install

CMD ["npm", "start"]

And package.json

  "name": "updials-auth",
  "version": "0.0.2",
  "author": "Sisir K. Adhikari <....>",
  "description": "This is a microservice auth server example forked from Oauth2rizeRecipe",
  "license": "MIT",
  "main": "app.js",
  "dependencies": {---},
  "scripts": {
    "lint": "eslint *.js config db test",
    "start": "node app.js",
    "test": "mocha test test/db test/config",
    "test:watch": "npm run test -- --watch",
    "test:integration": "mocha test/integration",
    "dev:api": "json-server json-server.db.json --port 4000",
    "migrate": "npx sequelize-cli db:migrate",
    "migrate:undo": "npx sequelize-cli db:migrate:undo",
    "migrate:undo:all": "npx sequelize-cli db:migrate:undo:all",
    "seed": "npx sequelize-cli db:seed:all",
    "keys": "cd certs && openssl genrsa -out privatekey.pem 2048 && openssl req -new -key privatekey.pem -out certrequest.csr && openssl x509 -req -in certrequest.csr -signkey privatekey.pem -out certificate.pem && cd ../"
  "engines": {
    "node": ">=6.7.0",
    "npm": ">=3.10.0"
  "devDependencies": {---}

I have done docker-compose down to remove instances and I even tried CMD['node', 'app.js'] in dockerfile but the old error still shows when I do docker-compose up.

Can anyone help me solve this problem?

running docker-compose build resolved the issue.