laverdet/isolated-vm

Error: /lowcode/node_modules/isolated-vm/out/isolated_vm.node: invalid ELF header

Closed this issue · 2 comments

Is Your Question Already Answered?

Personal Diagnostics

Please answer the following questions:

JavaScript includes a setTimeout function:

  • Yes
  • No

Functions are a type of primitive value in JavaScript:

  • Yes
  • No

Objects can be shared between isolates:

  • Yes
  • No

The Code

  • This code will parse and evaluate if I put it into a file called main.mjs and then run node main.mjs.

Am facing the below issue in Docker, i tried ignoring node_modules in my .dockerignore as mentioned here

Error: /lowcode/node_modules/isolated-vm/out/isolated_vm.node: invalid ELF header
at Module._extensions..node (node:internal/modules/cjs/loader:1460:18)
at Module.load (node:internal/modules/cjs/loader:1203:32)
at Module._load (node:internal/modules/cjs/loader:1019:12)
at Module.require (node:internal/modules/cjs/loader:1231:19)
at require (node:internal/modules/helpers:177:18)
at Object.<anonymous> (/lowcode/node_modules/isolated-vm/isolated-vm.js:1:18)
at Module._compile (node:internal/modules/cjs/loader:1364:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
at Module.load (node:internal/modules/cjs/loader:1203:32)
at Module._load (node:internal/modules/cjs/loader:1019:12) {
code: 'ERR_DLOPEN_FAILED'

If my file has below snippet, am seeing the above error during docker up, if i remove that its running fine. My node version is 18 and even tried v20.

const ivm = require("isolated-vm");

You need to run npm install from inside the container, not outside. And ignore node_modules.

https://www.docker.com/blog/getting-started-with-docker-using-node-jspart-i/

COPY package.json package.json
COPY package-lock.json package-lock.json
RUN npm install

Got that, was trying the same earlier and now found the root cause, volume mount is causing the issue, resolved. Thanks for the prompt response! Appreciated.