$ touch whatever.wasm
$ npm init
...
$ npm i @wasmer/sdk
...
# Create index.js
$ vim index.js
...
$ node index.js
TypeError: Cannot read properties of undefined (reading 'wasmer_fromFile')
at u_.fromFile (file:///Users/bryanhu/projects/Experiments/Ayu/node_modules/@wasmer/sdk/dist/index.mjs:11:21439)
at runWasm (file:///Users/bryanhu/projects/Experiments/Ayu/index.node.js:9:31)
// index.js
import { Wasmer } from "@wasmer/sdk";
import { promises as fs } from "fs";
async function runWasm() {
// Read the WASM file
const wasmBytes = await fs.readFile("whatever.wasm");
// Instantiate the Wasmer module
const cowsay = await Wasmer.fromFile(wasmBytes);
// Run the entrypoint with the given arguments
const instance = await cowsay.entrypoint.run({
args: '"Hello world"',
});
// Wait for the instance to complete and get the output
const output = await instance.wait();
console.log(output);
}
runWasm().catch(console.error);
Describe the bug
Steps to reproduce
Expected behavior
Actual behavior
Additional context