I am in the process of creating a package for Scrypted but fail to achieve building the @scrypted/node-pty
dependency.
Scrypted uses a Node/npm environment, and I have managed to configure most of it. You can view the progress of the package derivation at my current test branch.
The issue is the @scrypted/node-pty
dependency, which uses node-gyp
. After failing to fetch a prebuild version, it tries to build it, but errors because node-addon-api
is not available.
...
scrypted> npm error code 1
scrypted> npm error path /build/source/server/node_modules/@scrypted/node-pty
scrypted> npm error command failed
scrypted> npm error command sh -c prebuild-install || node-gyp rebuild
scrypted> npm error prebuild-install warn install getaddrinfo EAI_AGAIN github.com
scrypted> npm error gyp info it worked if it ends with ok
scrypted> npm error gyp info using node-gyp@10.1.0
scrypted> npm error gyp info using node@20.18.1 | linux | x64
scrypted> npm error gyp info find Python using Python version 3.12.8 found at "/nix/store/c9m6yd8fg1flz2j5r4bif1ib5j20a0cy-python3-3.12.8/bin/python3"
scrypted> npm error gyp WARN read config.gypi ENOENT: no such file or directory, open '/nix/store/qwrzxkqmsspprgq9s5j8bcr45lkign4k-nodejs-22.11.0-source/include/node/config.gypi'
scrypted> npm error gyp info spawn /nix/store/c9m6yd8fg1flz2j5r4bif1ib5j20a0cy-python3-3.12.8/bin/python3
scrypted> npm error gyp info spawn args [
scrypted> npm error gyp info spawn args '/nix/store/j7dx1n6m5axf9r2bvly580x2ixx546wq-nodejs-20.18.1/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
scrypted> npm error gyp info spawn args 'binding.gyp',
scrypted> npm error gyp info spawn args '-f',
scrypted> npm error gyp info spawn args 'make',
scrypted> npm error gyp info spawn args '-I',
scrypted> npm error gyp info spawn args '/build/source/server/node_modules/@scrypted/node-pty/build/config.gypi',
scrypted> npm error gyp info spawn args '-I',
scrypted> npm error gyp info spawn args '/nix/store/j7dx1n6m5axf9r2bvly580x2ixx546wq-nodejs-20.18.1/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
scrypted> npm error gyp info spawn args '-I',
scrypted> npm error gyp info spawn args '/nix/store/qwrzxkqmsspprgq9s5j8bcr45lkign4k-nodejs-22.11.0-source/common.gypi',
scrypted> npm error gyp info spawn args '-Dlibrary=shared_library',
scrypted> npm error gyp info spawn args '-Dvisibility=default',
scrypted> npm error gyp info spawn args '-Dnode_root_dir=/nix/store/qwrzxkqmsspprgq9s5j8bcr45lkign4k-nodejs-22.11.0-source',
scrypted> npm error gyp info spawn args '-Dnode_gyp_dir=/nix/store/j7dx1n6m5axf9r2bvly580x2ixx546wq-nodejs-20.18.1/lib/node_modules/npm/node_modules/node-gyp',
scrypted> npm error gyp info spawn args '-Dnode_lib_file=/nix/store/qwrzxkqmsspprgq9s5j8bcr45lkign4k-nodejs-22.11.0-source/$(Configuration)/node.lib',
scrypted> npm error gyp info spawn args '-Dmodule_root_dir=/build/source/server/node_modules/@scrypted/node-pty',
scrypted> npm error gyp info spawn args '-Dnode_engine=v8',
scrypted> npm error gyp info spawn args '--depth=.',
scrypted> npm error gyp info spawn args '--no-parallel',
scrypted> npm error gyp info spawn args '--generator-output',
scrypted> npm error gyp info spawn args 'build',
scrypted> npm error gyp info spawn args '-Goutput_dir=.'
scrypted> npm error gyp info spawn args ]
...
scrypted> npm error Error: Cannot find module 'node-addon-api'
scrypted> npm error Require stack:
scrypted> npm error - /build/source/server/node_modules/@scrypted/node-pty/[eval]
scrypted> npm error at Module._resolveFilename (node:internal/modules/cjs/loader:1225:15)
scrypted> npm error at Module._load (node:internal/modules/cjs/loader:1051:27)
scrypted> npm error at Module.require (node:internal/modules/cjs/loader:1311:19)
scrypted> npm error at require (node:internal/modules/helpers:179:18)
scrypted> npm error at [eval]:1:1
scrypted> npm error at runScriptInThisContext (node:internal/vm:209:10)
scrypted> npm error at node:internal/process/execution:118:14
scrypted> npm error at [eval]-wrapper:6:24
scrypted> npm error at runScript (node:internal/process/execution:101:62)
scrypted> npm error at evalScript (node:internal/process/execution:133:3) {
scrypted> npm error code: 'MODULE_NOT_FOUND',
scrypted> npm error requireStack: [ '/build/source/server/node_modules/@scrypted/node-pty/[eval]' ]
scrypted> npm error }
The full log output can be found in this gist: EACCES.zsh · GitHub.
First, I assumed it was a direct node-gyp
issue, but it seems that node-addon-api
is not available because it is a development dependency. I am currently trying to install the dependency by modifying the original package.json upfront, but so far, I have had no luck.
Any help to solve the issue is appreciated.
Thank you!
Steps to reproduce
- Checkout GitHub - omares/nix-homelab at add-scrypted
- Run
nix build .#scrypted --system x86_64-linux -L --show-trace
Technical details
My host machine is a aarch64-darwin
system, although my package is built on a x86_64-linux
remote builder.
Attached the nix-info output of said builder
root@build-01:~/ > nix-shell -p nix-info --run "nix-info -m"
- system: `"x86_64-linux"`
- host os: `Linux 6.6.63, NixOS, 25.05 (Warbler), 25.05pre-git`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.24.10`
- nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`