What does exit code 126 mean?

I had this issue earlier when trying to deploy but with the exit code 127. I tried changing my npm install to have the production set to false and that ended up just changing the exit code.

failed to fetch an image or build from source: error building: executor failed running [/bin/sh -c npm install && npm run build]: exit code: 126

I’m not sure what to send that would be super helpful with fixing this. I got advice earlier to check my $PATH but I couldn’t find any issues and npm seems accessible.

My docker:

RUN mkdir /app
WORKDIR /app

# NPM will not install any package listed in "devDependencies" when NODE_ENV is set to "production",
# to install all modules: "npm install --production=false".
# Ref: https://docs.npmjs.com/cli/v9/commands/npm-install#description

ENV NODE_ENV production

COPY . .

RUN npm install && npm run build
FROM debian:bullseye

LABEL fly_launch_runtime="nodejs"

COPY --from=builder /root/.volta /root/.volta
COPY --from=builder /app /app

WORKDIR /app
ENV NODE_ENV production
ENV PATH /root/.volta/bin:$PATH

CMD [ "npm", "run", "start" ]

My toml:

app = "fitnesstracking"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[env]
  PORT = "8080"

[experimental]
  allowed_public_ports = []
  auto_rollback = true

[[services]]
  http_checks = []
  internal_port = 8080
  processes = ["app"]
  protocol = "tcp"
  script_checks = []
  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

  [[services.ports]]
    force_https = true
    handlers = ["http"]
    port = 80

  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443

  [[services.tcp_checks]]
    grace_period = "1s"
    interval = "15s"
    restart_limit = 0
    timeout = "2s"

Hi @AgoraphobicClimber, The 127 error indicates the image does not have the npm binary installed. Can you double check that is your complete Dockerfile? It should have another FROM image:version.

I excluded the first few lines because I didn’t see anyone else include them, but I don’t see a FROM image:version line anywhere. Would I have to add that manually?

Here’s the lines I left out if it helps:

FROM debian:bullseye as builder

ARG NODE_VERSION=16.17.0

RUN apt-get update; apt install -y curl
RUN curl https://get.volta.sh | bash
ENV VOLTA_HOME /root/.volta
ENV PATH /root/.volta/bin:$PATH
RUN volta install node@${NODE_VERSION}

I think you should trying debugging with the following:

Change your Dockerfile to:

FROM debian:bullseye

ARG NODE_VERSION=16.17.0

RUN apt-get update; apt install -y curl
RUN curl https://get.volta.sh | bash
ENV VOLTA_HOME /root/.volta
ENV PATH /root/.volta/bin:$PATH
RUN volta install node@${NODE_VERSION}
RUN mkdir /app
WORKDIR /app

ENV NODE_ENV production

COPY . .

CMD [ "sleep", "100000" ]

Deploy then:

fly ssh console -a <your-app-name>

From the shell you can manually run npm install then npm run build and see if there are any errors.

Just want to preface, thanks a ton, I appreciate the help so much, this finally got me past the deploy errors which have been giving me a headache for days now. I ran npm install in the shell and got:

Tracker "idealTree" already exists

I read it’s an error having to do with node version 15 where it’s being executed in the root directory, which is confusing because like you sent in your docker it should be executing from usr/app.

1 Like