gpt4 book ai didi

node.js - OpenShift :/lib64/libz. so.1 上的 NodeJS 应用程序:未找到版本 `ZLIB_1.2.9'

转载 作者:搜寻专家 更新时间:2023-11-01 00:04:10 24 4
gpt4 key购买 nike

我是 Stackoverflow 的新手,所以向大家打招呼!

我也是 OpenShift Online(免费入门帐户)部署的新手。在部署需要 NPM-package sharp ( https://www.npmjs.com/package/sharp) 的个人 NodeJS 应用程序时,我遇到了以下错误。

该应用程序是直接来自本地 Git 存储库的“二进制构建”( https://docs.openshift.com/container-platform/3.6/dev_guide/dev_tutorials/binary_builds.html )。开始构建时,我得到以下输出(初始的相关行):

Receiving source from STDIN as archive ...
Pulling image "docker-registry.default.svc:5000/openshift/nodejs@sha256:0486de81685b610e47314d8b100c4cfae65edb3294d02f0a29ea57408e171fb6" ...
---> Installing application source ...
---> Installing all dependencies

> sharp@0.20.5 install /opt/app-root/src/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.6.1/libvips-8.6.1-linux-x64.tar.gz
prebuild-install WARN install /lib64/libz.so.1: version `ZLIB_1.2.9' not found (required by /opt/app-root/src/node_modules/sharp/build/Release/../../vendor/lib/libpng16.so.16)
...

构建完成并自动触发新部署,但启动失败,当然:

Environment: 
DEV_MODE=false
NODE_ENV=production
DEBUG_PORT=5858
Launching via npm...
npm info it worked if it ends with ok
npm info using npm@5.6.0
npm info using node@v8.9.4
...
> node app.js

module.js:672
return process.dlopen(module, path._makeLong(filename));
^

Error: /lib64/libz.so.1: version `ZLIB_1.2.9' not found (required by /opt/app-root/src/node_modules/sharp/build/Release/../../vendor/lib/libpng16.so.16)
at Object.Module._extensions..node (module.js:672:18)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/opt/app-root/src/node_modules/sharp/lib/constructor.js:10:15)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/opt/app-root/src/node_modules/sharp/lib/index.js:3:15)
at Module._compile (module.js:643:30)

我在 Electron ( https://github.com/lovell/sharp/issues/892 ) 的上下文中或当也使用 node-canvas 时(我不使用; https://github.com/lovell/sharp/issues/843 )发现了几个关于此错误的讨论。我很难提取与我的案例相关的信息,因为我也不熟悉 Dockers 等。

sharp 包在我的本地机器 (Ubuntu 16.04) 上安装良好,因此,该应用程序运行良好。我还尝试在我的主 app.js 文件中明确要求将 sharp 作为第一行,但这没有帮助。

感谢您的帮助,谢谢!

7 月 2 日编辑:从上述与 Electron 相关的讨论中,我想到了设置环境变量

LD_PRELOAD="/opt/app-root/src/node_modules/sharp/vendor/lib/libz.so"

在 OpenShift 上 NodeJS 应用程序的构建环境中。构建日志更改如下:

Receiving source from STDIN as archive ...
Pulling image "docker-registry.default.svc:5000/openshift/nodejs@sha256:0486de81685b610e47314d8b100c4cfae65edb3294d02f0a29ea57408e171fb6" ...
ERROR: ld.so: object '/opt/app-root/src/node_modules/sharp/vendor/lib/libz.so' from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object '/opt/app-root/src/node_modules/sharp/vendor/lib/libz.so' from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object '/opt/app-root/src/node_modules/sharp/vendor/lib/libz.so' from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object '/opt/app-root/src/node_modules/sharp/vendor/lib/libz.so' from LD_PRELOAD cannot be preloaded: ignored.
---> Installing application source ...
ERROR: ld.so: object '/opt/app-root/src/node_modules/sharp/vendor/lib/libz.so' from LD_PRELOAD cannot be preloaded: ignored.
---> Installing all dependencies
ERROR: ld.so: object '/opt/app-root/src/node_modules/sharp/vendor/lib/libz.so' from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object '/opt/app-root/src/node_modules/sharp/vendor/lib/libz.so' from LD_PRELOAD cannot be preloaded: ignored.

> sharp@0.20.5 install /opt/app-root/src/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

ERROR: ld.so: object '/opt/app-root/src/node_modules/sharp/vendor/lib/libz.so' from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object '/opt/app-root/src/node_modules/sharp/vendor/lib/libz.so' from LD_PRELOAD cannot be preloaded: ignored.
info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.6.1/libvips-8.6.1-linux-x64.tar.gz
added 170 packages in 19.982s

构建期间的警告消失了,但应用程序仍未启动,并出现与之前完全相同的错误。 (是的,我确实在主 app.js 中首先加载了 sharp。)

我不能以某种方式直接告诉 NodeJS(在主 app.js 中)优先选择某些路径(或库)吗?

最佳答案

至此我解决了这个问题。将 LD_PRELOAD 变量添加到构建和部署环境没有帮助。但是,一旦我修改了 npm 启动脚本以在启动应用程序之前添加变量,它就起作用了:

"start": "LD_PRELOAD='/opt/app-root/src/node_modules/sharp/vendor/lib/libz.so' node app.js"

在我的主 app.js 文件中,我仍然需要 sharp 作为第一件事;没有测试这是否真的有必要。

关于node.js - OpenShift :/lib64/libz. so.1 上的 NodeJS 应用程序:未找到版本 `ZLIB_1.2.9',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51122526/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com