'Can anyone help fixing my error on installing isolated-vm?

I run into the following error installing the npm package isolated VM on Debian 11: https://www.npmjs.com/package/isolated-vm

The log doesn't help me that much...

npm ERR! code 1
npm ERR! path /home/screeps/screeps-server/node_modules/isolated-vm
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild --release -j 4
npm ERR! make: Entering directory '/home/screeps/screeps-server/node_modules/isolated-vm/build'
npm ERR!   CXX(target) Release/obj.target/nortti/src/external_copy/serializer_nortti.o
npm ERR!   CXX(target) Release/obj.target/nortti/src/isolate/allocator_nortti.o
npm ERR!   AR(target) Release/obj.target/nortti.a
npm ERR!   COPY Release/nortti.a
npm ERR!   CXX(target) Release/obj.target/isolated_vm/src/external_copy/external_copy.o
npm ERR!   CXX(target) Release/obj.target/isolated_vm/src/external_copy/serializer.o
npm ERR!   CXX(target) Release/obj.target/isolated_vm/src/external_copy/string.o
npm ERR!   CXX(target) Release/obj.target/isolated_vm/src/isolate/environment.o
npm ERR!   CXX(target) Release/obj.target/isolated_vm/src/isolate/executor.o
npm ERR!   CXX(target) Release/obj.target/isolated_vm/src/isolate/holder.o
npm ERR!   CXX(target) Release/obj.target/isolated_vm/src/isolate/inspector.o
npm ERR!   CXX(target) Release/obj.target/isolated_vm/src/isolate/platform_delegate.o
npm ERR!   CXX(target) Release/obj.target/isolated_vm/src/isolate/scheduler.o
npm ERR!   CXX(target) Release/obj.target/isolated_vm/src/isolate/stack_trace.o
npm ERR!   CXX(target) Release/obj.target/isolated_vm/src/isolate/three_phase_task.o
npm ERR!   CXX(target) Release/obj.target/isolated_vm/src/lib/thread_pool.o
npm ERR!   CXX(target) Release/obj.target/isolated_vm/src/lib/timer.o
npm ERR!   CXX(target) Release/obj.target/isolated_vm/src/module/callback.o
npm ERR!   CXX(target) Release/obj.target/isolated_vm/src/module/context_handle.o
npm ERR!   CXX(target) Release/obj.target/isolated_vm/src/module/evaluation.o
npm ERR!   CXX(target) Release/obj.target/isolated_vm/src/module/external_copy_handle.o
npm ERR!   CXX(target) Release/obj.target/isolated_vm/src/module/isolate.o
npm ERR!   CXX(target) Release/obj.target/isolated_vm/src/module/isolate_handle.o
npm ERR!   CXX(target) Release/obj.target/isolated_vm/src/module/lib_handle.o
npm ERR!   CXX(target) Release/obj.target/isolated_vm/src/module/module_handle.o
npm ERR!   CXX(target) Release/obj.target/isolated_vm/src/module/native_module_handle.o
npm ERR!   CXX(target) Release/obj.target/isolated_vm/src/module/reference_handle.o
npm ERR!   CXX(target) Release/obj.target/isolated_vm/src/module/script_handle.o
npm ERR!   CXX(target) Release/obj.target/isolated_vm/src/module/session_handle.o
npm ERR!   CXX(target) Release/obj.target/isolated_vm/src/module/transferable.o
npm ERR!   SOLINK_MODULE(target) Release/obj.target/isolated_vm.node
npm ERR! make: Leaving directory '/home/screeps/screeps-server/node_modules/isolated-vm/build'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | linux | x64
npm ERR! gyp info find Python using Python version 3.9.2 found at "/usr/bin/python3"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/screeps/screeps-server/node_modules/isolated-vm/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/screeps/.cache/node-gyp/12.22.5/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/home/screeps/.cache/node-gyp/12.22.5',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/home/screeps/.cache/node-gyp/12.22.5/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/home/screeps/screeps-server/node_modules/isolated-vm',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build', '--jobs', 4 ]
npm ERR! ../src/isolate/environment.cc:25: warning: "_GNU_SOURCE" redefined
npm ERR!    25 | #define _GNU_SOURCE
npm ERR!       |
npm ERR! <command-line>: note: this is the location of the previous definition
npm ERR! ../src/module/lib_handle.cc: In member function 'v8::Local<v8::Value> ivm::LibHandle::PrivateSymbol(v8::MaybeLocal<v8::String>)':
npm ERR! ../src/module/lib_handle.cc:58:10: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
npm ERR!    58 |  return *reinterpret_cast<Local<Value>*>(&symbol);
npm ERR!       |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! ../src/module/lib_handle.cc:58:10: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
npm ERR! /usr/bin/ld: cannot find -lbrotlidec
npm ERR! /usr/bin/ld: cannot find -lbrotlienc
npm ERR! /usr/bin/ld: cannot find -lcares
npm ERR! /usr/bin/ld: cannot find -lnghttp2
npm ERR! /usr/bin/ld: cannot find -licui18n
npm ERR! /usr/bin/ld: cannot find -licuuc
npm ERR! /usr/bin/ld: cannot find -licudata
npm ERR! collect2: error: ld returned 1 exit status
npm ERR! make: *** [isolated_vm.target.mk:229: Release/obj.target/isolated_vm.node] Error 1
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (events.js:314:20)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12)
npm ERR! gyp ERR! System Linux 4.19.0
npm ERR! gyp ERR! command "/usr/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release" "-j" "4"
npm ERR! gyp ERR! cwd /home/screeps/screeps-server/node_modules/isolated-vm
npm ERR! gyp ERR! node -v v12.22.5
npm ERR! gyp ERR! node-gyp -v v9.0.0
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/screeps/.npm/_logs/2022-05-03T11_59_47_268Z-debug-0.log

I can't open the log afterwards because the folder gets already deleted.

Something has to be up with the libs: lbrotlidec, lbrotlienc

Any ideas, how to fix this?



Solution 1:[1]

Check if the version of NodeJS that you are currently using is compatible with the version of isolated-vm that you are trying to install.

https://www.npmjs.com/package/isolated-vm#requirements

For example, I was trying to install another library and I was getting a similar error, my version of node was 16, downgraded it to 12 and no more errors.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tyler2P