Using npm to install spago@next with the node:22 image on Docker fails with an error

I am trying to set up a Docker development environment with PureScript. While trying to install Spago, I get an error from the Docker builder. I am using the “node:22” image as a starting point.

Minimum example Dockerfile:

FROM node:22 AS dev

RUN    npm install -g purescript

RUN    npm install -g spago@next

Output:

2.745 npm warn deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
56.14 npm error code 1
56.14 npm error path /usr/local/lib/node_modules/spago/node_modules/better-sqlite3
56.14 npm error command failed
56.14 npm error command sh -c prebuild-install || node-gyp rebuild --release
56.14 npm error make: Entering directory '/usr/local/lib/node_modules/spago/node_modules/better-sqlite3/build'
56.14 npm error   TOUCH ba23eeee118cd63e16015df367567cb043fed872.intermediate
56.14 npm error   ACTION deps_sqlite3_gyp_locate_sqlite3_target_copy_builtin_sqlite3 ba23eeee118cd63e16015df367
567cb043fed872.intermediate
56.14 npm error   TOUCH Release/obj.target/deps/locate_sqlite3.stamp
56.14 npm error   CC(target) Release/obj.target/sqlite3/gen/sqlite3/sqlite3.o
56.14 npm error rm -f Release/obj.target/deps/sqlite3.a Release/obj.target/deps/sqlite3.a.ar-file-list; mkdir -
p `dirname Release/obj.target/deps/sqlite3.a`
56.14 npm error ar crs Release/obj.target/deps/sqlite3.a @Release/obj.target/deps/sqlite3.a.ar-file-list
56.14 npm error   COPY Release/sqlite3.a
56.14 npm error   CXX(target) Release/obj.target/better_sqlite3/src/better_sqlite3.o
56.14 npm error rm ba23eeee118cd63e16015df367567cb043fed872.intermediate
56.14 npm error make: Leaving directory '/usr/local/lib/node_modules/spago/node_modules/better-sqlite3/build'
56.14 npm error prebuild-install warn install No prebuilt binaries found (target=22.2.0 runtime=node arch=x64 l
ibc= platform=linux)
56.14 npm error gyp info it worked if it ends with ok
56.14 npm error gyp info using node-gyp@10.1.0
56.14 npm error gyp info using node@22.2.0 | linux | x64
56.14 npm error gyp info find Python using Python version 3.11.2 found at "/usr/bin/python3"
56.14 npm error gyp http GET https://nodejs.org/download/release/v22.2.0/node-v22.2.0-headers.tar.gz
56.14 npm error gyp http 200 https://nodejs.org/download/release/v22.2.0/node-v22.2.0-headers.tar.gz
56.14 npm error gyp http GET https://nodejs.org/download/release/v22.2.0/SHASUMS256.txt
56.14 npm error gyp http 200 https://nodejs.org/download/release/v22.2.0/SHASUMS256.txt
56.14 npm error gyp info spawn /usr/bin/python3
56.14 npm error gyp info spawn args [
56.14 npm error gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
56.14 npm error gyp info spawn args 'binding.gyp',
56.14 npm error gyp info spawn args '-f',
56.14 npm error gyp info spawn args 'make',
56.14 npm error gyp info spawn args '-I',
56.14 npm error gyp info spawn args '/usr/local/lib/node_modules/spago/node_modules/better-sqlite3/build/config
.gypi',
56.14 npm error gyp info spawn args '-I',
56.14 npm error gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
56.14 npm error gyp info spawn args '-I',
56.14 npm error gyp info spawn args '/root/.cache/node-gyp/22.2.0/include/node/common.gypi',
56.14 npm error gyp info spawn args '-Dlibrary=shared_library',
56.14 npm error gyp info spawn args '-Dvisibility=default',
56.14 npm error gyp info spawn args '-Dnode_root_dir=/root/.cache/node-gyp/22.2.0',
56.14 npm error gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
56.14 npm error gyp info spawn args '-Dnode_lib_file=/root/.cache/node-gyp/22.2.0/<(target_arch)/node.lib',
56.14 npm error gyp info spawn args '-Dmodule_root_dir=/usr/local/lib/node_modules/spago/node_modules/better-sq
lite3',
56.14 npm error gyp info spawn args '-Dnode_engine=v8',
56.14 npm error gyp info spawn args '--depth=.',
56.14 npm error gyp info spawn args '--no-parallel',
56.14 npm error gyp info spawn args '--generator-output',
56.14 npm error gyp info spawn args 'build',
56.14 npm error gyp info spawn args '-Goutput_dir=.'
56.14 npm error gyp info spawn args ]
56.14 npm error gyp info spawn make
56.14 npm error gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
56.14 npm error In file included from ./src/better_sqlite3.lzz:11,
56.14 npm error                  from ../src/better_sqlite3.cpp:4:
56.14 npm error /root/.cache/node-gyp/22.2.0/include/node/node.h:1248:7: warning: cast between incompatible fun
ction types from 'void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, v8::Local<v8::Context>)' to 'node::addo
n_context_register_func' {aka 'void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, v8::Local<v8::Context>, vo
id*)'} [-Wcast-function-type]
56.14 npm error  1248 |       (node::addon_context_register_func) (regfunc),                  \
56.14 npm error       |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
56.14 npm error /root/.cache/node-gyp/22.2.0/include/node/node.h:1266:3: note: in expansion of macro 'NODE_MODU
LE_CONTEXT_AWARE_X'
56.14 npm error  1266 |   NODE_MODULE_CONTEXT_AWARE_X(modname, regfunc, NULL, 0)
56.14 npm error       |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
56.14 npm error /root/.cache/node-gyp/22.2.0/include/node/node.h:1297:3: note: in expansion of macro 'NODE_MODU
LE_CONTEXT_AWARE'
56.14 npm error  1297 |   NODE_MODULE_CONTEXT_AWARE(NODE_GYP_MODULE_NAME,                     \
56.14 npm error       |   ^~~~~~~~~~~~~~~~~~~~~~~~~
56.14 npm error ./src/better_sqlite3.lzz:67:1: note: in expansion of macro 'NODE_MODULE_INIT'
56.14 npm error ./src/util/macros.lzz: In function 'void SetPrototypeGetter(v8::Isolate*, v8::Local<v8::Externa
l>, v8::Local<v8::FunctionTemplate>, const char*, v8::AccessorGetterCallback)':
56.14 npm error ./src/util/macros.lzz:150:46: error: no matching function for call to 'v8::ObjectTemplate::SetA
ccessor(v8::Local<v8::String>, void (*&)(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>&), in
t, v8::Local<v8::External>&, v8::AccessControl, v8::PropertyAttribute)'
56.14 npm error In file included from /root/.cache/node-gyp/22.2.0/include/node/v8-function.h:15,
56.14 npm error                  from /root/.cache/node-gyp/22.2.0/include/node/v8.h:33,
56.14 npm error                  from /root/.cache/node-gyp/22.2.0/include/node/node.h:73:
56.14 npm error /root/.cache/node-gyp/22.2.0/include/node/v8-template.h:1055:8: note: candidate: 'void v8::Obje
ctTemplate::SetAccessor(v8::Local<v8::Name>, v8::AccessorNameGetterCallback, v8::AccessorNameSetterCallback, v8
::Local<v8::Value>, v8::PropertyAttribute, v8::SideEffectType, v8::SideEffectType)'
56.14 npm error  1055 |   void SetAccessor(
56.14 npm error       |        ^~~~~~~~~~~
56.14 npm error /root/.cache/node-gyp/22.2.0/include/node/v8-template.h:1058:61: note:   no known conversion fo
r argument 5 from 'v8::AccessControl' to 'v8::PropertyAttribute'
56.14 npm error  1058 |       Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
56.14 npm error       |                                           ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
56.14 npm error /root/.cache/node-gyp/22.2.0/include/node/v8-template.h:1049:8: note: candidate: 'void v8::Obje
ctTemplate::SetAccessor(v8::Local<v8::String>, v8::AccessorGetterCallback, v8::AccessorSetterCallback, v8::Loca
l<v8::Value>, v8::PropertyAttribute, v8::SideEffectType, v8::SideEffectType)'
56.14 npm error  1049 |   void SetAccessor(
56.14 npm error       |        ^~~~~~~~~~~
56.14 npm error /root/.cache/node-gyp/22.2.0/include/node/v8-template.h:1052:61: note:   no known conversion fo
r argument 5 from 'v8::AccessControl' to 'v8::PropertyAttribute'
56.14 npm error  1052 |       Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
56.14 npm error       |                                           ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
56.14 npm error ./src/util/data.lzz: In function 'v8::Local<v8::Value> Data::GetValueJS(v8::Isolate*, sqlite3_s
tmt*, int, bool)':
56.14 npm error ./src/util/data.lzz:73:92: warning: this statement may fall through [-Wimplicit-fallthrough=]
56.14 npm error ./src/util/data.lzz:73:197: note: here
56.14 npm error ./src/util/data.lzz: In function 'v8::Local<v8::Value> Data::GetValueJS(v8::Isolate*, sqlite3_v
alue*, bool)':
56.14 npm error ./src/util/data.lzz:77:81: warning: this statement may fall through [-Wimplicit-fallthrough=]
56.14 npm error ./src/util/data.lzz:77:175: note: here
56.14 npm error make: *** [better_sqlite3.target.mk:120: Release/obj.target/better_sqlite3/src/better_sqlite3.o
] Error 1
56.14 npm error gyp ERR! build error
56.14 npm error gyp ERR! stack Error: `make` failed with exit code: 2
56.14 npm error gyp ERR! stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-g
yp/lib/build.js:209:23)
56.14 npm error gyp ERR! System Linux 5.15.146.1-microsoft-standard-WSL2
56.14 npm error gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/b
in/node-gyp.js" "rebuild" "--release"
56.14 npm error gyp ERR! cwd /usr/local/lib/node_modules/spago/node_modules/better-sqlite3
56.14 npm error gyp ERR! node -v v22.2.0
56.14 npm error gyp ERR! node-gyp -v v10.1.0
56.14 npm error gyp ERR! not ok
56.14
56.14 npm error A complete log of this run can be found in: /root/.npm/_logs/2024-06-07T00_04_46_743Z-debug-0.l
og
------
failed to solve: process "/bin/sh -c npm install -g spago@next" did not complete
successfully: exit code: 1

Given that this is a Docker build it should be relatively easy to reproduce. I believe the key line is prebuild-install warn install No prebuilt binaries found (target=22.2.0 runtime=node arch=x64 libc= platform=linux).

I think you are right here.

Maybe you could open an issue on the Repo for Spago?

BTW: Node 20 works fine - maybe you can use Node 20? It’s LTS and should be supported for quite some time still.

This should now be fixed in the latest version! (0.93.32)

1 Like