Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

1.8K
Visualizações
Docker - /bin/sh: nodemon: not found

I have the following docker file.

#Dockerfile

FROM node:alpine

WORKDIR /backend

COPY package*.json .

RUN yarn

COPY . .

EXPOSE 5000

CMD ["yarn", "dev"]

Nodemon works as intended on host machine but shows the following error message when running the container.

yarn run v1.22.5
$ nodemon
/bin/sh: nodemon: not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Nodemon is not installed globally in the host machine. Adding RUN yarn add global nodemon on Dockerfile just adds an extra warning ../package.json: No license field in the container error.

I currently have the following package.json file with the following dev dependencies

# package.json
...
"scripts": {
    "build": "tsc -p .",
    "start": "node ./dist/src/index.js",
    "dev": "nodemon",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "devDependencies": {
    "@types/express": "^4.17.11",
    "@types/node": "^14.14.34",
    "nodemon": "^2.0.7",
    "ts-node": "^9.1.1",
    "typescript": "^4.2.3"
  },
...

and nodemon.json as

{
    "watch": [
      "src"
    ],
    "ext": "ts,json",
    "ignore": [
        "src/**/*.spec.ts"
    ],
    "exec": "yarn ts-node src/index.ts"
  }
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Try with below,

#Dockerfile

FROM node:alpine

WORKDIR /backend

COPY package*.json .

RUN yarn

RUN yarn add global nodemon

COPY . .

EXPOSE 5000

CMD ["yarn", "dev"]

SIDE NOTE: You better not using nodemon in production. Serve build files as in your start script. You have to add the build command before yarn start.

#Dockerfile

FROM node:alpine

WORKDIR /backend

COPY package*.json .

RUN yarn

COPY . .

RUN yarn run build

EXPOSE 5000

CMD ["yarn", "start"]
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda