question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error loading shared library ... Exec format error

See original GitHub issue

Hi!

I’m trying to run sharp inside a node:alpine container but I’m having lots of trouble, after reading issue #988 I’ve managed to get it to compile but it crashes at runtime.

This is the dockerfile I’m using.

FROM node:alpine
RUN apk update && apk add --update nodejs-npm
RUN apk add vips-dev fftw-dev --update-cache --repository https://dl-3.alpinelinux.org/alpine/edge/testing/

RUN apk --no-cache add -t .build-deps \
        gcc \
        libc-dev\
        make \
        libpng-dev \
        g++ \
        git && \
    mkdir -p /opt/google && \
    cd /opt/google && \
    git clone https://github.com/google/guetzli.git && \
    cd guetzli && \
    make && \
    cd /opt  && \
    mv /opt/google/guetzli/bin/Release/guetzli . && \
    rm -fr /opt/google && \
    apk --no-cache add libpng libstdc++

ENV TZ=Europe/Dublin
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

WORKDIR /usr/server

COPY ./shared /usr/app/shared
COPY ./server /usr/app/server

WORKDIR /usr/app/shared
RUN npm install

WORKDIR /usr/app/server

RUN npm install -g ts-node typescript && npm install && npm run build

EXPOSE 3005

ENTRYPOINT npm run dev

I can see sharp it’s getting built during npm install

> sharp@0.20.8 install /usr/app/server/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

info sharp Detected globally-installed libvips v8.6.3
info sharp Building from source via node-gyp
make: Entering directory '/usr/app/server/node_modules/sharp/build'
  TOUCH Release/obj.target/libvips-cpp.stamp
  CXX(target) Release/obj.target/sharp/src/common.o
  CXX(target) Release/obj.target/sharp/src/metadata.o
  CXX(target) Release/obj.target/sharp/src/stats.o
  CXX(target) Release/obj.target/sharp/src/operations.o
  CXX(target) Release/obj.target/sharp/src/pipeline.o
  CXX(target) Release/obj.target/sharp/src/sharp.o
  CXX(target) Release/obj.target/sharp/src/utilities.o
  SOLINK_MODULE(target) Release/obj.target/sharp.node
  COPY Release/sharp.node
make: Leaving directory '/usr/app/server/node_modules/sharp/build'

But the moment I do (Using typescript) import * as sharp from 'sharp'

I get the following error: Error: Error loading shared library /usr/app/server/node_modules/sharp/build/Release/sharp.node: Exec format error

It’s there something I’m missing? Thank you!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
lovellcommented, Sep 12, 2018

Hello, my best guess would be that the COPY directives are populating node_modules directories inside the container with (OS X?) contents from outside the container.

2reactions
konradovskycommented, Sep 30, 2020

For me the problem was that I didn’t specify the .dockerignore on the root folder precise enough. I needed to add **/node_modules and not node_module

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - Docker compose up 'Exec format error' loading a library
It is not a problem related to docker. But the reason it fails to run inside docker is that there are some packages...
Read more >
Exec format error when loading a .so module into Apache
Solved: Hi, I'm installing SAP Content Server on a HP-UX server. SAP's Content Server requires 64-Bit Apache, so I downloaded Apache's ...
Read more >
docker-compose up 'Exec format error' - DevJT
After executing npm install bcrypt . Running docker-compose up to build the NestJs app, this error will show.
Read more >
exec user process caused "exec format error" - balena Forums
Started getting this error, reverted to old version that was working but still displays the error even when the new build uploads.
Read more >
Could not load module. System error: Exec format error." when ...
64-bit version of the library (typically by pointing to /usr/lib/lib_64). Example. setenv LIBPATH /usr/lib/lib_64:{$LIBPATH}. After this change, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found