由于 bigint 错误,我的 Javascript 文件不会 运行
My Javascript file won't run because of bigint error
我正在尝试使用@metaplex/js 进行一些 NFT 铸造。通常我的 .js 文件可以正常工作,但是当我 运行 文件时出现此错误。
bigint:加载绑定失败,将使用纯JS(试试npm 运行 rebuild?)
我真的不明白那是什么意思。所以,我尝试 运行 npm 运行 rebuild 但据说 rebuild 是一个丢失的脚本,我找不到安装它的方法。
这是我的代码:
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();
如果您有任何想法,或者只是对我的错误含义的解释,我将不胜感激。
您收到此错误是因为嵌套依赖项的编译步骤可能无法在您的平台上成功。 This issue 提供了很好的解释。
[...] 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.
但是,这应该会给您一个警告,并且仍然允许您编译代码。
值得注意的是,Metaplex 当前的 JS SDK 将被弃用,取而代之的是新的:https://github.com/metaplex-foundation/js-next
使用新的 JS SDK,您可以使用以下代码获取 NFT。
import { Metaplex } from "@metaplex-foundation/js-next";
import { Connection, clusterApiUrl } from "@solana/web3.js";
const connection = new Connection(clusterApiUrl("mainnet-beta"));
const metaplex = new Metaplex(connection);
const mint = new PublicKey("ATe3DymKZadrUoqAMn7HSpraxE4gB88uo1L9zLGmzJeL");
const nft = await metaplex.nfts().findByMint(mint);
我正在尝试使用@metaplex/js 进行一些 NFT 铸造。通常我的 .js 文件可以正常工作,但是当我 运行 文件时出现此错误。
bigint:加载绑定失败,将使用纯JS(试试npm 运行 rebuild?)
我真的不明白那是什么意思。所以,我尝试 运行 npm 运行 rebuild 但据说 rebuild 是一个丢失的脚本,我找不到安装它的方法。
这是我的代码:
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();
如果您有任何想法,或者只是对我的错误含义的解释,我将不胜感激。
您收到此错误是因为嵌套依赖项的编译步骤可能无法在您的平台上成功。 This issue 提供了很好的解释。
[...] 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.
但是,这应该会给您一个警告,并且仍然允许您编译代码。
值得注意的是,Metaplex 当前的 JS SDK 将被弃用,取而代之的是新的:https://github.com/metaplex-foundation/js-next
使用新的 JS SDK,您可以使用以下代码获取 NFT。
import { Metaplex } from "@metaplex-foundation/js-next";
import { Connection, clusterApiUrl } from "@solana/web3.js";
const connection = new Connection(clusterApiUrl("mainnet-beta"));
const metaplex = new Metaplex(connection);
const mint = new PublicKey("ATe3DymKZadrUoqAMn7HSpraxE4gB88uo1L9zLGmzJeL");
const nft = await metaplex.nfts().findByMint(mint);