I am encountering an issue with my Javascript file not running due to a bigint error

I'm attempting to utilize @metaplex/js for NFT minting. Usually, my .js files function correctly, but when I execute the file, this particular error arises.

bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)

The meaning of this escapes me. Thus, I attempted to execute npm run rebuild, only to discover that 'rebuild' is a missing script and I couldn't locate a way to install it.

Below is my code snippet:

import { Connection, programs} from "@metaplex/js";
import { Loader } from "@solana/web3.js";
const { metadata: {Metadata}} = programs;

const connection = new Connection("devnet");
const tokenPublicKey = 'my_adress';

const run = async() => {
    try{
        const ownedMetadata = await Metadata.Loader(connection,tokenPublicKey)
        console.log(ownedMetadata)
    }
    catch{
        console.log('Failed to fetch')
    }

};

run();

If you have any insights or an explanation regarding the nature of my error, I would greatly appreciate it.

Answer №1

The error you are encountering is due to a nested dependency that includes a compilation step which may not be compatible with your platform. For more details, refer to this resource.

[...] The issue arises because one of the dependencies (bigint-buffer) undergoes a compilation process during installation, which can fail for various reasons. One common reason is the absence of necessary build tools on your system. While you can install these tools on Windows from here, it automatically switches to a pure JS solution if needed. Nevertheless, that warning message can indeed be quite annoying.

Despite the warning message, you should still be able to compile your code successfully.

Note that the existing JS SDK by Metaplex will soon be replaced by a new version: https://github.com/metaplex-foundation/js-next

Using the updated JS SDK, you can retrieve an NFT using the following code snippet:

import { Metaplex } from "@metaplex-foundation/js";
import { Connection, clusterApiUrl } from "@solana/web3.js";

const connection = new Connection(clusterApiUrl("mainnet-beta"));
const metaplex = new Metaplex(connection);
const mintAddress = new PublicKey("ATe3DymKZadrUoqAMn7HSpraxE4gB88uo1L9zLGmzJeL");

const nft = await metaplex.nfts().findByMint({ mintAddress });

Answer №2

I encountered a similar issue recently while setting up acceptance tests in a Docker environment using a lightweight image based on node:21.4.0-bookworm-slim. The use of the *-slim tag indicates that the image contains only essential preinstalled packages.

FROM node:21.4.0-bookworm-slim

WORKDIR /code
COPY package* tsconfig.json /code
RUN npm install

Although the warning about bigint-buffer was not causing any failures, it raised performance concerns during test execution. To address this issue, I needed to eliminate these warnings from my terminal.

$ docker compose exec client npm run test:acceptance

> <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="295a4645484748044a45404c475d691807190719">[email protected]</a> test:acceptance
... 

Even after running npm run rebuild as recommended, the problem persisted. Upon further investigation, I discovered that bigint-buffer relies on native C bindings for optimal performance, necessitating specific dependencies on the host system for successful compilation.

The build process is facilitated by node-gyp, which outlines the required dependencies in its documentation. In my Debian setup, installing python3 and build-essential before npm install resolved the issue:

RUN apt update \
    && apt install --assume-yes --no-install-recommends \
        build-essential \
        python3

If you're working locally, ensure to install comparable dependencies on your machine. The key is to have the necessary tools available to support native big number optimization without encountering any warnings.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Enhance the speed of my Tumblr page by using JavaScript for personalized styling tweaks

-- Hey there! Dear Reader, if navigating Tumblr isn't your cup of tea, let me know and I'll provide more detailed instructions! I recently ran into some glitches on my Tumblr page while using the default theme 'Optica'. Whenever I tri ...

Encountered an issue retrieving tweets from the Twitter API 1.1

I recently completed an online tutorial from this site: However, I'm encountering an error message that simply says 'error: ' without any additional information. To start, here is my PHP script used to fetch the JSON output: <?php sess ...

Utilizing Ajax to fetch a div element from a web page

Hey there! I have a link set up that loads a page into a specific div ID, which is #ey_4col3. The issue I'm facing is that it loads the entire page along with all its contents, but what I really want to load from that page is just the content within ...

Javascript is not functioning properly when making an ajax call

Having a bit of trouble with JavaScript not working after an Ajax call. Everything functions normally until new data is fetched from the database or an Ajax call is made. The issue seems to be that the JavaScript doesn't load properly. Any help would ...

Difficulty encountered when trying to use Bootstrap tooltip with Bootstrap icon

Attempting to implement bootstrap tooltips on bootstrap icons with the following code: <body> <script> const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]') ...

Is it recommended for synchronous code invoked by a Promise's .then method to generate a fresh Promise

I recently wrote some code containing a mix of asynchronous and synchronous functions. Here's an example: function handleAsyncData() { asyncFunction() .then(syncTask) .catch(error); } After some research, I learned that the then method is ...

The local types package cannot be built by react-scripts even though tsc has successfully completed the process

I have developed an application with a TypeScript frontend and backend. To streamline the process, I decided to create a shared types module that contains all the necessary types for both components in one centralized location. Rather than going through th ...

The error message "MediaMetadata is not defined as no-undef and cannot be used as a constructor" appeared when trying to use MediaMetadata

I have successfully implemented a playlist player using howler.js in vuejs. Now, I am looking to enhance it by integrating the MediaMetadata API. While the MediaSession API is functioning well with controls like notification bar, keyboard controls, and rem ...

I am looking to host several iterations of jQuery on a content delivery network within my Nuxt application

Currently, we are loading jQuery 3.1.4 externally from a CDN on the top page. index.vue head: { bodyAttrs: { id: 'overview' }, script: [ { src: 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min ...

Experimenting with the input type generated by the Form Helper tool

Before generating the form using Form Helper, is there a method to preview the type of input it will produce? I would like to confirm whether it will result in a select or multi-select element before loading the page. ...

How can I verify if an SVG file has a reliable source? (having troubles converting SVG to canvas)

While attempting to use an SVG generated by a chart plugin (https://wordpress.org/plugins/visualizer/), I am facing issues retrieving the source of the SVG-image being created. Interestingly, when using other SVGs with the same code, everything works perfe ...

Displaying an array within a method using Vue.js

As a complete newcomer to Vue, I wanted to experiment with methods a bit. Specifically, I attempted to print out an array of strings using the following method: printStringArray(objectWithArray) { i = 0; s = ''; while(i < ob ...

Click the link to capture the ID and store it in a variable

Currently working on a project involving HTML and JavaScript. Two HTML pages ("people.html" and "profile.html") are being used along with one JavaScript file ("people.js") that contains an object with a list of names, each assigned a unique ID: var person ...

What is the best approach for writing a concise Select statement that produces a data list?

Currently, I am working on a small web application using Express.js and SQLite for local use. However, I am facing an issue when trying to perform a full select query on a table. All my scripts are written in JScript in 'use-strict' mode. I am a ...

Trigger animation once you've scrolled past a designated point in the document

I created a count-up counter animation using JavaScript, but the issue is that the counter starts animating as soon as I refresh the page regardless of where I am on the page or if the counter is even visible. I would like the counter to only start workin ...

Retrieve a JSON WebMap using an ArcGIS JavaScript API Map object

Is there a way to retrieve a JSON representation of a WebMap object from a JavaScript Map object in the ArcGIS JavaScript API without relying on ArcGIS.com? It would be ideal if there was a method similar to: webMapAsJSON = map.toWebMap(); The "Export We ...

Unlocking the secrets of obtaining post values using Body-parser in your Express Node.js application

Currently, I am utilizing Express version 4.11.1 and Body-parser version 1.11.0 in my project. However, upon running the code snippet below, I encountered the following output: I am seeking suggestions on how to retrieve the form value. Output {} serve ...

How can I deactivate a Material UI button after it has been clicked once?

Looking to make a button disabled after one click in my React project that utilizes the MUI CSS framework. How can I achieve this functionality? <Button variant="contained" onClick={()=>handleAdd(course)} disabled={isDisabled} > ...

A step-by-step guide on how to fill a Vuetify select box with data retrieved from

I'm currently working on populating a select box in Vuetify by retrieving data through an ajax call. I'm struggling to figure out how to populate the select box with this data. The ajax call is successful and I receive an array of objects which I ...