I am attempting to install sodium native as an npm package on OpenBSD 7.3 amd64.
Aside: As a dependency of Hypercore, Hyperbee and Corestore.
This needs node-gyp.
Following this, I set the C and C++ compilers to clang:
export CC=clang
export CXX=clang++
I created a directory example
and, for development/debugging only, I set the permissions via chmod 777
.
I then used npm init
to create an empty package.json
file.
On running npm install sodium-native
, I get the following error logs:
395 info run sodium-native@4.0.1 install node_modules/sodium-native node-gyp-build
396 info run sodium-native@4.0.1 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 sodium-native@4.0.1
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 node-gyp@9.3.1
410 error gyp info using node@18.15.0 | 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
The node_modules directory did not get created. I am unsure how to interpret this. I think perhaps that node-gyp is not finding binding.gyp. I note that there is a binding.gyp in the repo. Could there be an error in how it is downloaded? Where should it be on my system (find . -name "binding.gyp"
implies that it is within the node-pledge module /usr/local/lib/node_modules/node-pledge/binding.gyp
), is this right?
What does error code 1 mean? What might be going wrong here? What next steps could I take?
There are a lot of questions with this error on SE, but no good explanations of what is going on and why. Is there a high level process description that would help; e.g. what is GYP doing? what is node-gyp doing, and what is node-gyp-build doing?
Here are a small portion of the questions with this error:
https://github.com/prebuild/node-gyp-build/issues/8
https://github.com/nodejs/node-gyp/issues/809
Note: this is an adapted cross-post of this.