Skip to content
Advertisement

My Javascript file won’t run because of bigint error

I am trying to use @metaplex/js to do some NFT minting. Usually my .js files work properly but when I run the file this error comes up.

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

I don’t really get what that means. So, I tried to run npm run rebuild but rebuild is said to be a missing script and I couldn’t find a way to install it.

Here is my code:

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 idea, or simply an explanation of what my error means, I’d be grateful.

Advertisement

Answer

You are getting this error because a nested dependency has a compilation step that might not succeed in your platform. This issue provides a good explanation.

[…] This happens because one of our dependencies (bigint-buffer) runs a compilation step on installation and this can step may fail for a couple of reasons. One of the reasons is that your system might not have the build-tools the library is looking for. You can install these build tools on Windows (see https://www.npmjs.com/package/windows-build-tools), but you don’t actually need to as it automatically falls back to a pure JS solution instead. Though I agree… that warning is very annoying.

However, this should give you a warning and still allow you to compile your code.

It is worth noting that the current JS SDK from Metaplex is going to be deprecated in favour of the new one: https://github.com/metaplex-foundation/js-next

With the new JS SDK, you can fetch an NFT using the following piece of code.

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 });
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement