None of the answers above go to the root cause of the issue and won't solve it, depending on how you are building the environment and running the application.
In my case, the error was occurring in an acceptance tests setup using a very simple docker image starting from node:21.4.0-bookworm-slim
. Notice the *-slim
part, which means an image with the absolute minimal preinstalled packages.
FROM node:21.4.0-bookworm-slim
WORKDIR /code
COPY package* tsconfig.json /code
RUN npm install
Of course, running the tests, which happens to use bigint-buffer
, was displaying the warning. Although nothing was failing, it was a performance concern (maybe...). In any case, I can't sleep with these warnings polluting my terminal.
$ docker compose exec client npm run test:acceptance
> [email protected] test:acceptance
> rm -rf ./dist/* && tsc && node --test dist/*.test.js
bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)
✔ reads own balance (53.348432ms)
▶ creates/deletes PDA
✔ fails for non-admin user (12.346694ms)
✔ fails for insuficient lamports (7.776273ms)
...
Running npm run rebuild
as suggested inside the container didn't help. Digging deeper, it turns out that bigint-buffer
uses native C bindings for performance reasons, but as such it requires certain dependencies to exist on the host to compile the file written in C. In case these dependencies are not there, it will fallback gracefully to JS implementation, which will still work, but will be less performant.
The build is performed by a tool called node-gyp
. This is not very clear from the bigint-buffer
perspective, but in node-gyp
the dependencies are clearly described in their README:
- A supported version of
Python
make
- A proper C/C++ compiler toolchain, like
GCC
In my Debian setup, all I needed was to install python3
and build-essential
(which contains make
and gcc
), adding the following to the Dockerfile
before running npm install
(so the OS dependencies are there when bigint-buffer
is installed by npm
):
RUN apt update \
&& apt install --assume-yes --no-install-recommends \
build-essential \
python3
If you are running this locally, of course you can just install the equivalent dependencies directly on your computer. Of course if you are using another distro, MacOS or Windows you'll need different dependencies, but the spirit is same.
And done! Optimized native big numbers are now used and no warning is displayed anymore!