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.

Import fails when using node alpine docker image

See original GitHub issue

I’m using the docker image node:alpine3.11 to build and deploy my application.

internal/modules/cjs/loader.js:1197
 return process.dlopen(module, path.toNamespacedPath(filename));

Error: Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /usr/app/node_modules/sodium-native/prebuilds/linux-x64/libsodium.so.23)
 at Object.Module._extensions..node (internal/modules/cjs/loader.js:1197:18)
 at Module.load (internal/modules/cjs/loader.js:996:32)
 at Function.Module._load (internal/modules/cjs/loader.js:896:14)
 at Module.require (internal/modules/cjs/loader.js:1036:19)
 at require (internal/modules/cjs/helpers.js:72:18)
 at load (/usr/app/node_modules/node-gyp-build/index.js:21:10)
 at Object.<anonymous> (/usr/app/node_modules/sodium-native/index.js:1:39)
 at Module._compile (internal/modules/cjs/loader.js:1147:30)
 at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
 at Module.load (internal/modules/cjs/loader.js:996:32)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
marcbachmanncommented, May 4, 2021

This might be helpful to others. I’m using the following Dockerfile instructions using alpine linux. The environment variable helps in finding the prebuilt version:

FROM node:15-alpine
RUN apk add --no-cache --virtual build-deps python alpine-sdk autoconf libtool automake && \
  mkdir -p /prebuilds && cd /prebuilds && npm init -y && npm install sodium-native@3.1.1 && \
  apk del build-deps
ENV SODIUM_NATIVE_PREBUILD=/prebuilds/node_modules/sodium-native/

and a new version with node 16 (includes python3 instead of python2):

FROM node:16-alpine
RUN apk add --no-cache --virtual build-deps python3 alpine-sdk autoconf libtool automake && \
  mkdir -p /prebuilds && cd /prebuilds && npm init -y && npm install sodium-native@3.1.1 && \
  apk del build-deps
ENV SODIUM_NATIVE_PREBUILD=/prebuilds/node_modules/sodium-native/
0reactions
dyc3commented, Apr 21, 2020

The node:alpine3.11 tag runs the latest version of node (13.13.0) on alpine 3.11

Read more comments on GitHub >

github_iconTop Results From Across the Web

Docker Node Alpine Image Build Fails on node-gyp
I'm attempting to Dockerize a Vue. js application. I'm using the node:10.15-alpine Docker image as a base. The image build fails with the ......
Read more >
Multi-stage builds - Docker Documentation
When you run the build.sh script, it needs to build the first image, create a container from it to copy the artifact out,...
Read more >
Running under Docker - Node-RED
This guide assumes you have some basic familiarity with Docker and the Docker Command Line. It describes some of the many ways Node-RED...
Read more >
Use kaniko to build Docker images - GitLab Documentation
If you receive this error, it might be due to an outside proxy. Setting the http_proxy and https_proxy environment variables can fix the...
Read more >
10 best practices to containerize Node.js web applications ...
js Docker team. The Node.js image bundles the Alpine operating system which is powered by the minimal busybox software tooling and the musl...
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