本文介绍了Linux上的Node-oracledb无效的ELF标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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)

我用不同的节点版本(8和9)进行了尝试,但是相同的错误不断弹出,这表明我的图像设置可能存在问题,但我不知道是什么原因.这是dockerfile:

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" ]

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

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

推荐答案

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

You need to add node_modules to .dockerignore then remove it node_modules

这篇关于Linux上的Node-oracledb无效的ELF标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 06:41