OpenBSD:npm installodium-native,解释错误消息

OpenBSD:npm installodium-native,解释错误消息

我正在尝试安装钠原作为 OpenBSD 7.3 amd64 上的 npm 包。

旁白:作为依赖项Hypercore、Hyperbee 和 Corestore

这需要节点 gyp

下列的,我将 C 和 C++ 编译器设置为 clang:

export CC=clang
export CXX=clang++

我创建了一个目录example,并且仅用于开发/调试,我通过chmod 777.

然后我用来npm init创建一个空package.json文件。

运行时npm install sodium-native,我收到以下错误日志:

395 info run [email protected] install node_modules/sodium-native node-gyp-build
396 info run [email protected] install { code: 1, signal: null }
397 timing reify:rollback:createSparse Completed in 4183ms
398 timing reify:rollback:retireShallow Completed in 0ms
399 timing command:install Completed in 31258ms
400 verbose stack Error: command failed
400 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/@npmcli/promise-spawn/lib/index.js:53:27)
400 verbose stack     at ChildProcess.emit (node:events:513:28)
400 verbose stack     at maybeClose (node:internal/child_process:1091:16)
400 verbose stack     at Socket.<anonymous> (node:internal/child_process:449:11)
400 verbose stack     at Socket.emit (node:events:513:28)
400 verbose stack     at Pipe.<anonymous> (node:net:322:12)
401 verbose pkgid [email protected]
402 verbose cwd /example
403 verbose OpenBSD 7.3
404 verbose node v18.15.0
405 verbose npm  v9.5.0
406 error code 1
407 error path /example/node_modules/sodium-native
408 error command failed
409 error command sh -c node-gyp-build
410 error gyp info it worked if it ends with ok
410 error gyp info using [email protected]
410 error gyp info using [email protected] | openbsd | x64
410 error gyp info find Python using Python version 3.10.11 found at "/usr/local/bin/python3"
410 error gyp info spawn /usr/local/bin/python3
410 error gyp info spawn args [
410 error gyp info spawn args   '/usr/local/lib/node_modules/node-gyp/gyp/gyp_main.py',
410 error gyp info spawn args   'binding.gyp',
410 error gyp info spawn args   '-f',
410 error gyp info spawn args   'make',
410 error gyp info spawn args   '-I',
410 error gyp info spawn args   '/example/node_modules/sodium-native/build/config.gypi',
410 error gyp info spawn args   '-I',
410 error gyp info spawn args   '/usr/local/lib/node_modules/node-gyp/addon.gypi',
410 error gyp info spawn args   '-I',
410 error gyp info spawn args   '/root/.cache/node-gyp/18.15.0/include/node/common.gypi',
410 error gyp info spawn args   '-Dlibrary=shared_library',
410 error gyp info spawn args   '-Dvisibility=default',
410 error gyp info spawn args   '-Dnode_root_dir=/root/.cache/node-gyp/18.15.0',
410 error gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/node-gyp',
410 error gyp info spawn args   '-Dnode_lib_file=/root/.cache/node-gyp/18.15.0/<(target_arch)/node.lib',
410 error gyp info spawn args   '-Dmodule_root_dir=/example/node_modules/sodium-native',
410 error gyp info spawn args   '-Dnode_engine=v8',
410 error gyp info spawn args   '--depth=.',
410 error gyp info spawn args   '--no-parallel',
410 error gyp info spawn args   '--generator-output',
410 error gyp info spawn args   'build',
410 error gyp info spawn args   '-Goutput_dir=.'
410 error gyp info spawn args ]
410 error node:events:491
410 error       throw er; // Unhandled 'error' event
410 error       ^
410 error
410 error Error: write EPIPE
410 error     at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:94:16)
410 error Emitted 'error' event on Socket instance at:
410 error     at Socket.onerror (node:internal/streams/readable:785:14)
410 error     at Socket.emit (node:events:513:28)
410 error     at emitErrorNT (node:internal/streams/destroy:151:8)
410 error     at emitErrorCloseNT (node:internal/streams/destroy:116:3)
410 error     at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
410 error   errno: -32,
410 error   code: 'EPIPE',
410 error   syscall: 'write'
410 error }
410 error
410 error Node.js v18.15.0
410 error gyp: Call to 'node deps/bin.js --print-include' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
410 error gyp ERR! configure error 
410 error gyp ERR! stack Error: `gyp` failed with exit code: 1
410 error gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/node-gyp/lib/configure.js:325:16)
410 error gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
410 error gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:291:12)
410 error gyp ERR! System OpenBSD 7.3
410 error gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
410 error gyp ERR! cwd /example/node_modules/sodium-native
410 error gyp ERR! node -v v18.15.0
410 error gyp ERR! node-gyp -v v9.3.1
410 error gyp ERR! not ok
411 verbose exit 1
412 timing npm Completed in 31440ms
413 verbose unfinished npm timer reify 1683196282136
414 verbose unfinished npm timer reify:build 1683196305333
415 verbose unfinished npm timer build 1683196305334
416 verbose unfinished npm timer build:deps 1683196305334
417 verbose unfinished npm timer build:run:install 1683196305349
418 verbose unfinished npm timer build:run:install:node_modules/sodium-native 1683196307572
419 verbose code 1
420 error A complete log of this run can be found in:
420 error     /root/.npm/_logs/2023-05-04T10_31_22_018Z-debug-0.log

未创建 node_modules 目录。我不确定如何解释这一点。我不清楚这是权限问题、编译器工具链问题还是其他问题。

这里可能出了什么问题?接下来我可以采取哪些步骤?


编辑: 进一步的调查:

这个问题可以更直接地重现,如下所示:

pkg_add git
git clone --branch v3.3.0 https://github.com/sodium-friends/sodium-native
pkg_add node
cd s*
node deps/bin.js --print-include --print-lib --print-arch

使用console.logs indeps/bin.js缩小了在进程对象上创建的套接字的问题范围运行函数,当传递 'tar' 和 'xzv' 参数时(在尝试从https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz);什么时候它尝试在套接字之间进行管道传输。我看见,并想知道 OpenBSD 是否有任何原因可能会过早关闭套接字?

可能相关的链接:

https://stackoverflow.com/questions/39739626/what-is-node-gyp https://stackoverflow.com/questions/58436786/build-of-sodium-native-on-centos-cloud-is-failing https://stackoverflow.com/questions/39855232/npm-install-fails-with-node-gyp-build-error https://github.com/prebuild/node-gyp-build/issues/8

https://github.com/nodejs/node-gyp/issues/809


注:改编并交叉发布 这里

答案1

可以像这样安装 3.2.1 版本:

npm i [email protected]

在此之前,我已经完成了以下操作(不确定上述操作是否需要这样做):

pkg_add git
git clone --branch v3.2.1 https://github.com/sodium-friends/sodium-native
cd s*
pkg_add libsodium
pkg_add libtool
pkg_add autoconf
export AUTOCONF_VERSION=2.71 #choose your version
pkg_add automake
export AUTOMAKE_VERSION=1.16 #choose your version
npm install
npm test # check it installed ok

请注意,此半解决方案提供的模块与上游钠通用模块和超核模块一起使用时会导致错误。

相关内容