简体   繁体   中英

Node-oracledb invalid ELF header on linux

I'm using a dockerized setup of node-oracledb (based on docker-node-oracle) together with Node 10 but this error keeps popping up when I start the container:

backend_1  | /app/node_modules/oracledb/lib/oracledb.js:68
backend_1  |       throw new Error(nodbUtil.getErrorMessage('NJS-045', nodeInfo));
backend_1  |       ^
backend_1  |
backend_1  | Error: NJS-045: cannot load the oracledb add-on binary for Node.js 10.4.1 (linux, x64)
backend_1  | Cannot load /app/node_modules/oracledb/build/Release/oracledb.node
backend_1  | /app/node_modules/oracledb/build/Release/oracledb.node: invalid ELF header
backend_1  | Node-oracledb installation instructions: https://oracle.github.io/node-oracledb/INSTALL.html
backend_1  | You must have 64-bit Oracle client libraries in LD_LIBRARY_PATH, or configured with ldconfig.
backend_1  | If you do not have Oracle Database on this computer, then install the Instant Client Basic or Basic Light package from
backend_1  | http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
backend_1  |
backend_1  |     at Object.<anonymous> (/app/node_modules/oracledb/lib/oracledb.js:68:13)
backend_1  |     at Module._compile (internal/modules/cjs/loader.js:702:30)
backend_1  |     at Module._extensions..js (internal/modules/cjs/loader.js:713:10)
backend_1  |     at Object.require.extensions.(anonymous function) [as .js] (/app/node_modules/babel-register/lib/node.js:152:7)
backend_1  |     at Module.load (internal/modules/cjs/loader.js:612:32)
backend_1  |     at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
backend_1  |     at Function.Module._load (internal/modules/cjs/loader.js:543:3)
backend_1  |     at Module.require (internal/modules/cjs/loader.js:650:17)
backend_1  |     at require (internal/modules/cjs/helpers.js:20:18)
backend_1  |     at Object.<anonymous> (/app/node_modules/oracledb/index.js:1:18)

I've tried it with different node versions (8 and 9) but the same error keeps popping up which indicates that there might be a problem with the setup of my image but I can't figure out what. Here's the dockerfile:

# INSTALL UBUNTU
FROM node:10

#INSTALL LIBAIO1 & UNZIP (NEEDED FOR STRONG-ORACLE)
RUN apt-get update \
    && apt-get install -y libaio1 \
    && apt-get install -y build-essential \
    && apt-get install -y unzip \
    && apt-get install -y curl

#ADD ORACLE INSTANT CLIENT
RUN mkdir -p opt/oracle
ADD ./oracle/linux/ .

# 12.2
RUN unzip instantclient-basic-linux.x64-12.2.0.1.0 -d /opt/oracle \
    && mv /opt/oracle/instantclient_12_2 /opt/oracle/instantclient

RUN cd /opt/oracle/instantclient \
    && ln -s libclntsh.so.12.1 libclntsh.so \
    && ln -s libocci.so.12.1 libocci.so 

RUN echo /opt/oracle/instantclient > /etc/ld.so.conf.d/oracle-instantclient.conf

ENV LD_LIBRARY_PATH="/opt/oracle/instantclient"

WORKDIR app

ARG NODE_ENV
ENV NODE_ENV $NODE_ENV

COPY package.json .

RUN npm install

COPY . .
RUN ./build.sh

CMD [ "./up.sh" ]

Anyone who knows/had this problem with node-oracledb?

After help from Christopher at the above mentioned post I got it working. Together with his Dockerfile and a clean slate (deleting all Docker images/containers, restarting pc,...) I got it working. Thx for the help!

您需要将node_modules添加到 .dockerignore 然后将其删除 node_modules

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM