Home > Software design >  Nodemon failed to start process because node exec was not found
Nodemon failed to start process because node exec was not found

Time:07-25

New to this DevOps thing. So I'm trying to docker-compose my nodejs express app but I keep running into this error enter image description here

I'm not sure what that is or how to get rid of I've read some other posts that said run

npm install node --save-dev; tried that removed the images & container rebuilt and I'm still getting this error :(

Does anyone know why this is happenning? I'll post some files below maybe I missed something :/

Dockerfile

FROM node:latest

RUN mkdir -p /usr/src/app

WORKDIR /usr/src/app

RUN npm install -g nodemon

COPY package.json /usr/src/app

RUN npm install

COPY . /usr/src/app

EXPOSE 3081

CMD ["npm", "start"]

docker-compose

version: "3.3"
services:
    web:
        build: ./
        command: nodemon -L app.js
        ports:
            - "3081:3081"
        volumes:
            - ./:/usr/src/app
 

package.json

{
  "name": "docker-web-api",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "start": "nodemon -L app.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "async": "^3.2.4",
    "axios": "^0.27.2",
    "body-parser": "^1.20.0",
    "dotenv": "^16.0.1",
    "express": "^4.18.1",
    "mongoose": "^6.4.6",
    "node": "^18.5.0",
    "npm": "^8.15.0"
  },
  "devDependencies": {
    "nodemon": "^2.0.19"
  }
}

CodePudding user response:

The docker volume is removing your node models. Please add new entry as below to prevent.

 volumes:
    - ./:/usr/src/app
    - /usr/src/app/node_modules

Or else use name volume

     volumes:
        - volume_name:/usr/src/app    
  • Related