Sharp: Alpine Docker run, Error loading shared library libresolv.so.2: No such file or directory

Created on 30 Aug 2017  路  4Comments  路  Source: lovell/sharp

It Build successfully without throwing error but when i run that build it throws error.

module.js:598
return process.dlopen(module, path._makeLong(filename));
^

Error: Error loading shared library libresolv.so.2: No such file or directory (needed by /app/node_modules/sharp/build/Release/../../vendor/lib/librsvg-2.so.2)
at Object.Module._extensions..node (module.js:598:18)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object. (/app/node_modules/sharp/lib/constructor.js:9:15)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object. (/app/node_modules/sharp/lib/index.js:3:15)
at Module._compile (module.js:569:30)
npm info lifecycle [email protected]~start: Failed to exec start script

Here is Docker File:

FROM node:alpine

RUN apk update && apk upgrade

RUN apk add --no-cache --virtual .gyp \
python \
make \
g++
RUN apk add fftw-dev

RUN apk add vips-dev --update-cache --repository https://dl-3.alpinelinux.org/alpine/edge/testing/

RUN mkdir -p /app
ADD package.json /app
WORKDIR /app
ENV HOME /app
ENV NODE_ENV development

RUN npm install

COPY . /app
EXPOSE 3000
CMD npm start

question

Most helpful comment

@AhmedHassan07 Were you able to make any progress with this, e.g. by not copying node_modules built on a glibc-based Linux over the top of one destined for a musl-based Linux?

All 4 comments

Hello, my best guess would be that the COPY . /app command is overwriting the contents of /app/node_modules created by the RUN npm install command.

@AhmedHassan07 Were you able to make any progress with this, e.g. by not copying node_modules built on a glibc-based Linux over the top of one destined for a musl-based Linux?

It Build successfully without throwing error but when i run that build it throws error.

module.js:598
return process.dlopen(module, path._makeLong(filename));
^

Error: Error loading shared library libresolv.so.2: No such file or directory (needed by /app/node_modules/sharp/build/Release/../../vendor/lib/librsvg-2.so.2)
at Object.Module._extensions..node (module.js:598:18)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object. (/app/node_modules/sharp/lib/constructor.js:9:15)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object. (/app/node_modules/sharp/lib/index.js:3:15)
at Module._compile (module.js:569:30)
npm info lifecycle [email protected]~start: Failed to exec start script

Here is Docker File:

FROM node:alpine

RUN apk update && apk upgrade

RUN apk add --no-cache --virtual .gyp
python
make
g++
RUN apk add fftw-dev

RUN apk add vips-dev --update-cache --repository https://dl-3.alpinelinux.org/alpine/edge/testing/

RUN mkdir -p /app
ADD package.json /app
WORKDIR /app
ENV HOME /app
ENV NODE_ENV development

RUN npm install

COPY . /app
EXPOSE 3000
CMD npm start

Hi Ahmed,

How were you able to resolve the issue. I am facing the same issue while deploying this to azure

Try to look for the errors that are being thrown when sharp is building. If it is autoreconf not found then refer here

Was this page helpful?
0 / 5 - 0 ratings

Related issues

terbooter picture terbooter  路  3Comments

tomercagan picture tomercagan  路  3Comments

henbenla picture henbenla  路  3Comments

emmtte picture emmtte  路  3Comments

vermin1337 picture vermin1337  路  3Comments