Closed
Description
Hi, when following the steps at https://github.com/ruby/ruby.wasm/blob/main/docs/cheat_sheet.md#nodejs, I get the following error:
import { DefaultRubyVM } from "@ruby/wasm-wasi/dist/node";
^^^^^^^^^^^^^
SyntaxError: Named export 'DefaultRubyVM' not found. The requested module '@ruby/wasm-wasi/dist/node' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from '@ruby/wasm-wasi/dist/node';
const { DefaultRubyVM } = pkg;
If I copy node_modules/@ruby/3.2-wasm-wasi/dist/node.esm.js
locally and import it relatively, I don't get that error. However, I then get another error:
node:wasi:51
validateString(options.version, 'options.version');
^
TypeError [ERR_INVALID_ARG_TYPE]: The "options.version" property must be of type string. Received undefined
at new WASI (node:wasi:51:5)
at DefaultRubyVM (file:///home/blue/projects/primate-ffi/ruby/node.esm.js:1193:18)
at file:///home/blue/projects/primate-ffi/ruby/index.js:7:22 {
code: 'ERR_INVALID_ARG_TYPE'
}
I fixed this by changing the WASI instantiation code at line 1193 to
const wasi = new WASI({ env: options.env, version: 'preview1' });
Using Node v21.4.0.
Metadata
Metadata
Assignees
Labels
No labels