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

Adding child arrays to a parent array in Angular 8 using push method

Upon filtering the data, the response obtained inside the findChildrens function is as follows: My expectation now is that if the object length of this.newRegion is greater than 1, then merge the children of the second object into the parent object's ...

Maintain the fancybox open even in case of ajax errors

I'm having an issue with my code where the fancybox closes automatically after displaying the error message briefly. I want it to remain open so that users have more time to fix their errors. What could be causing this problem? $(document).ready(func ...

How to retrieve a random element from an array within a for loop using Angular 2

I'm in the process of developing a soundboard that will play a random sound each time a button is clicked. To achieve this, I have created an array within a for loop to extract the links to mp3 files (filename), and when a user clicks the button, the ...

Having trouble retrieving data from JSON using JavaScript

Hey folks, I need some help with the following code snippet: function retrieveClientIP() { $.getJSON("http://192.168.127.2/getipclient.php?callback=?", function(json) { eval(json.ip); });} This function is used to fetch the IP address of visitors. When i ...

Ways to implement logging in an NPM package without the need for a specific logging library

Currently, I am in the process of developing a company npm package using TypeScript and transferring existing code to it. Within the existing code, there are instances of console.log, console.warn, and console.error statements, as shown below: try { c ...

Tips on running methods consecutively within ngOnInit in Angular

I'm currently working on an ngoninit function that contains four methods. Two of these methods are responsible for retrieving data from the API, while the other two are intended to load this data when the page loads. ngOnInit(){ getname(); getsubjects ...

Is there a way to enhance the Download File dialog with an additional option?

I want to develop an extension for a specific file type, and I'm interested in including a "Send to MyAddonName" feature in the download file dialog, alongside the "Open with" and "Save file" options. Just to clarify, I don't mean the Download Ma ...

Having difficulty using the forEach() method to loop through the array generated by my API

During my troubleshooting process with console.log/debugger, I discovered that I am encountering an issue when attempting to iterate over the API generated array in the addListItem function's forEach method call. Interestingly, the pokemonNameList ar ...

What are the steps for integrating a CMS with my unique website design?

Currently, I am in the process of creating a unique website for a client using my own combination of html, css, and JavaScript. There is also a possibility that I may incorporate vueJS into the design. The client has expressed a desire to have the ability ...

`Inconsistencies between Postman and AngularJS service responses`

When I make a call to the endpoint using Postman, I receive this response: https://i.stack.imgur.com/pH31G.png However, when I make the same request from my AngularJS service defined below: this.login = function (loginInfo) { return $http({ ...

Introducing HTML elements into pre-existing web pages

My interest lies in the idea of injecting HTML into existing web pages for enhanced functionality. Specifically, I am exploring the concept of creating a more efficient bookmarking system. As someone new to web development, I am unsure of how to achieve th ...

The parameter of type 'never' cannot be assigned with the argument of type 'number | boolean | undefined'

In my project, I am creating a validation input using TypeScript in Next.js. interface InputRules { required?: boolean min?: number max?: number minLength?: number maxLength?: number } I have defined an object that contains methods to handle val ...

Problems with navigation, not functioning properly due to issues with Pulled functions

I am still getting the hang of things and struggling with the terminology, so please bear with me as I try to explain my issue. Currently, I am working on a project in react native where I have two files - Header.js and footer.js. I have successfully impo ...

The jQuery remove function will only take effect on the second click following an AJAX request

I'm facing an issue with my jQuery code where two divs contain lists of links, triggering AJAX calls to append JSON data to a separate div. Upon clicking a link, the corresponding link div should hide. There's also a third div with the class "pan ...

Why is my JSON parse function returning an empty string?

Not sure if the issue lies with VueJS or JS itself. Within my database, I have a string (converted from a JS Object using JSON.stringify()) that appears as follows: {"type":5,"values":{"7":"/data/images/structured-content/64-7-scico.jpg","8":"<b>we ...

Is it possible to use JavaScript or jQuery to call a WCF Service and retrieve a collection of System.IO.Stream objects?

I am developing a WCF service that will be utilized by plain JavaScript on the client side, as well as some jQuery JavaScript. 1) How can I set up the plain client JavaScript to call the WCF Service in a manner that retrieves a collection of System.IO.Str ...

Experiencing issues with connecting to jQuery in an external JavaScript file

My jQuery formatting in the HTML file looks like this: <!doctype html> <html lang="en"> <head> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js" type="text/javascript"></script> </head> < ...

Encountered an error stating 'Cannot read property 'user' of undefined' while attempting to generate a user document during account creation using Firebase

I'm having trouble adding the user ID to a new collection named 'accounts' during account creation. I keep encountering an error that says 'Cannot read property 'user' of undefined'. Can someone please help me troubleshoo ...

Can an XSS attack occur on a style tag with inline styling?

For example: <!DOCTYPE html> <html lang="en"> <head> <title>Test for Potential XSS Attack</title> <style> div { background-color:blue; height:120px; ...

Create type definitions for React components in JavaScript that utilize the `prop-types` library

Exploring a component structure, we have: import PropTypes from 'prop-types'; import React from 'react'; export default class Tooltip extends React.Component { static propTypes = { /** * Some children components */ ...