node.js - [TypeError: WebAssembly.instantiate(): Imports 参数必须存在并且必须是一个对象]
问题描述
我正在尝试将 golang WebAssembly 组件导入 NodeJS,但一直遇到这个问题:
[TypeError: WebAssembly.instantiate(): Imports argument must be present and must be an object]
我认为问题是我需要找到一种方法来包含它,wasm_exec.js
因为它可以在 Chrome 中使用。
这是我测试过的:
const fs = require('fs');
const buf = fs.readFileSync('./test.wasm');
async function asyncCall() {
try {
//listing messages in users mailbox
const lib = await WebAssembly.instantiate(new Uint8Array(buf)).then(res => res.instance.exports);
} catch (err) {
console.log(err)
}
console.log(res);
// expected output: 'resolved'
}
asyncCall();
解决方案
推荐阅读
- django - 如何解决我的 CPU 利用率问题,我正在使用带有 nginx、uwsgi 和 django 的 ubuntu ec2 实例
- kubernetes - k8s pvc 中的 aws-efs “ProvisioningFailed - 没有卷插件匹配”
- java - 在方法中从 1-10 生成 3 个随机数字的问题
- angular - 如何将“名称”绑定到路由器插座以呈现动态创建的 angular-cdk 组件
- python - 使用字典比较不同列中的行值
- oracle - 所有条目选择的 max_blocking_factor 和索引提示
- python - 如何使用信号在 Django 中基于用户属性创建特定配置文件
- cookies - 未在 iOS Safari 或 Chrome 中设置或发送请求的 Cookie 适用于所有 Android 和桌面浏览器
- c# - 如何测试 JSON 对象中的必填字段?
- continuous-integration - 如何在 Azure DevOps/TFS2018 中设置多个构建环境?