Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在阅读官方文档但没有找到此信息后提出这个问题。
我在 Node.js 上v8.1.3。如何在 Node.js 上的 JavaScript 中在 wast(WebAssembly 的文本表示)上编译和运行“hello world”?
v8.1.3
使用node-wasm加载您的 wasm 文件,然后在您的 node js 应用程序中,执行以下操作:
import loadWasm from 'node-wasm'; async function run() { const {rust_function} = await loadWasm('/local/path/to/wasm'); const result = rust_function(); console.log(result); } run();
在同一个 repo 中有一个完整的例子。祝你好运!