-
Notifications
You must be signed in to change notification settings - Fork 36
@wasmer/wasi: Document Demo Fail #152
Comments
I have the same problem. I tried to follow the official example in the docs, but it shows an error: Failed to resolve '@wasmer/wasi/lib/bindings/browser' from './src/index.js' Then try to run the official example for Nodejs, like this: import fs from "fs";
import { init, WASI } from "@wasmer/wasi";
// This is needed to load the WASI library first
await init();
let wasi = new WASI({
env: {},
args: [],
});
const buf = fs.readFileSync('./src/demo.wasm');
const module = await WebAssembly.compile(
new Uint8Array(buf)
);
await wasi.instantiate(module, {});
let exitCode = wasi.start();
let stdout = wasi.getStdoutString();
// This should print "hello world (exit code: 0)"
console.log(`${stdout}(exit code: ${exitCode})`); NodeJS works, but in the browser doesn't work, I tried adjusting the NodeJS example to browser using fetch, like this: import { init, WASI } from "@wasmer/wasi";
await init();
let wasi = new WASI({
env: {},
args: [],
});
let response = await fetch('/demo.wasm');
let wasmBytes = new Uint8Array(await response.arrayBuffer());
const module = await WebAssembly.compile(wasmBytes);
await wasi.instantiate(module, {});
let exitCode = wasi.start();
let stdout = wasi.getStdoutString();
// This should print "hello world (exit code: 0)"
console.log(`${stdout}(exit code: ${exitCode})`); But it shows the following error: Failed to resolve 'wasmer_wasi_js_bg.wasm' from './node_modules/@wasmer/wasi/dist/Library.esm.min.js' |
The missing |
The outdated reference to Also probably should add a note about the |
We have published a new version of |
The Demo in : https://docs.wasmer.io/integrations/js/reference-api/wasmer-wasi
That has am error:
Cannot resolve dependency '@wasmer/wasi/lib/bindings/browser
After look inside, @wasmer/wasi
"@wasmer/wasi": "^0.10.0"
has directorylib
in npm module, but the latest version does't.So, the question is, is there the way run wasi in browser?
The text was updated successfully, but these errors were encountered: