我的JavaScript文件赢了,因为BigInt错误会运行
我正在尝试使用 @metaplex/js进行一些NFT造币。通常,我的.js文件正常工作,但是当我运行文件时,此错误会出现。
bigint:无法加载绑定,将使用纯JS(尝试NPM运行重建?)
我真的没有得到什么含义。因此,我尝试运行NPM Run 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();
如果您有任何想法,或者仅仅解释了我的错误含义,我将不胜感激。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您会遇到此错误,因为嵌套的依赖性具有在平台中无法成功的汇编步骤。 此问题提供了一个很好的解释。
但是,这应该给您警告,并且仍然允许您编译代码。
值得注意的是,Metaplex的当前JS SDK将被弃用新的: https://github.com/metaplex-foundation/js-next
使用新的JS SDK,您可以使用以下代码获取NFT。
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.
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.
我也经历了这个问题。就我而言,它是在接受测试的设置中使用非常简单的docker映像开始的,从
节点开始:21.4.0-book worm-slim
。请注意* - Slim
零件,这是指具有绝对最小预装软件包的图像。当然,运行碰巧使用
bigint-buffer
的测试正在显示警告。尽管没有任何事情失败,但这是一个表演问题(也许...)。无论如何,我无法入睡这些警告污染我的航站楼。运行
NPM运行重建
在容器中建议的无济于事。更深入地挖掘,事实证明,出于绩效原因,bigint-buffer
使用本机C绑定,但是因此,如果这些依赖关系为不存在,它将优雅地退回JS实施,这仍然可以起作用,但性能较低。该构建由称为
node-gyp
的工具执行。从bigint-buffer
角度来看,这不是很清楚,但是在node-gyp
中,依赖项在其 readme :代码>
GCC
在我的Debian设置中,我所需要的只是安装
python3
和build> build-Essential
((其中包含make
和gcc
),将以下内容添加到dockerfile
之前运行运行npm npm install (因此,当
bigint-buffer
由> npm
安装时,OS依赖项就在那里:如果您在本地运行此此操作,那么您当然可以直接安装等效的依赖项在您的计算机上。当然,如果您使用另一个发行版,macos或窗口,则需要不同的依赖性,但是精神是相同的。
并完成了!现在使用了优化的本地大数字,并且不再显示警告!
I experienced this issue as well. In my case, it 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.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.Running
npm run rebuild
as suggested inside the container didn't help. Digging deeper, it turns out thatbigint-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 thebigint-buffer
perspective, but innode-gyp
the dependencies are clearly described in their README:Python
make
GCC
In my Debian setup, all I needed was to install
python3
andbuild-essential
(which containsmake
andgcc
), adding the following to theDockerfile
before runningnpm install
(so the OS dependencies are there whenbigint-buffer
is installed bynpm
):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!
为了处理警告“未能加载绑定,将使用纯JS(尝试NPM运行重建?)”在Bigint-Buffer模块中,如果它不影响您的功能,则可以将其注释。由于此警告表明未加载本机绑定,并且将使用纯JS后备,因此通常在大多数情况下都不关键。
To handle the warning "Failed to load bindings, pure JS will be used (try npm run rebuild?)" in the bigint-buffer module, you can comment it out if it doesn't affect your functionality. Since this warning suggests that a native binding isn't loaded and the pure JS fallback will be used, it typically isn't critical for most cases.