Linux上的Node-oracledb无效的ELF标头

时间:2018-06-20 14:50:25

标签: node.js docker oracledb

我正在使用Node-oracledb(基于docker-node-oracle)的dockerized设置以及Node 10,但是在启动容器时此错误不断弹出:

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)

我用不同的节点版本(8和9)进行了尝试,但是相同的错误不断弹出,表明我的图像设置可能存在问题,但我不知道是什么。这是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" ]

知道/有node-oracledb这个问题的人吗?

2 个答案:

答案 0 :(得分:0)

在上述职位的克里斯托弗(Christopher)的帮助下,我开始工作了。我连同他的Dockerfile和一个干净的平板(删除所有Docker映像/容器,重新启动pc,...)一起工作了。感谢您的帮助!

答案 1 :(得分:0)

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