wasmedge instantiate CLI
After installation, users can execute the wasmedge instantiate command.
The wasmedge instantiate command loads, validates, and instantiates a WebAssembly module. It checks that all imports can be resolved and that the module can be fully instantiated, but does not execute any functions. This is useful for verifying that a WASM module can be successfully linked and instantiated in a given environment before running it.
The wasmedge instantiate command also supports linking additional WASM modules, allowing you to verify that multi-module dependencies resolve correctly.
$ wasmedge instantiate -h
USAGE
wasmedge instantiate [OPTIONS] [--] WASM_OR_SO
...
Options
The options of the wasmedge instantiate command are as follows.
-h|--help: Show the help messages. Will ignore the other arguments below.- (Optional)
--log-level: Set logging level. Valid values:off,trace,debug,info,warning,error,fatal. Default isinfo. - (Optional)
--forbidden-plugin: List of plugins to ignore. - (Optional)
--module: Register additional WASM modules for linking. Each module can be specified as--module name:path, wherenameis the module name to export andpathis the WASM file path. This option can be repeated to register multiple modules. - (Optional)
--dir: Bind directories into WASI virtual filesystem.- Use
--dir guest_path:host_pathto bind the host path into the guest path in WASI virtual system.
- Use
- (Optional)
--env: Assign the environment variables in WASI.- Use
--env ENV_NAME=VALUEto assign the environment variable.
- Use
- (Optional)
--memory-page-limit: Set the limitation of pages (as size of 64 KiB) in every memory instance. - (Optional) WebAssembly proposals:
- Use
--wasm-1to set the environment as WASM 1.0 standard. This standard includes the following proposals: - Use
--wasm-2to set the environment as WASM 2.0 standard. This standard includes the WASM 1.0 and following proposals: - Use
--wasm-3to set the environment as WASM 3.0 standard (Currently default since 0.16.0). This standard includes the WASM 2.0 and following proposals: - Use
--disable-import-export-mut-globalsto disable the Import/Export of Mutable Globals proposal (DefaultON). - Use
--disable-non-trap-float-to-intto disable the Non-Trapping Float-to-Int Conversions proposal (DefaultON). - Use
--disable-sign-extension-operatorsto disable the Sign-Extension Operators proposal (DefaultON). - Use
--disable-multi-valueto disable the Multi-value proposal (DefaultON). - Use
--disable-bulk-memoryto disable the Bulk Memory Operations proposal (DefaultON). - Use
--disable-reference-typesto disable the Reference Types proposal (DefaultON). - Use
--disable-simdto disable the Fixed-width SIMD proposal (DefaultON). - Use
--disable-tail-callto disable the Tail call proposal (DefaultON). - Use
--disable-extended-constto disable the Extended Constant Expressions proposal (DefaultON). - Use
--disable-function-referenceto disable the Typed-Function References proposal (DefaultON). - Use
--disable-gcto disable the Garbage Collection proposal (DefaultON). - Use
--disable-multi-memoryto disable the Multiple Memories proposal (DefaultON). - Use
--disable-relaxed-simdto disable the Relaxed SIMD proposal (DefaultON). - Use
--disable-exception-handlingto disable the Exception Handling proposal (DefaultON). - Use
--enable-threadsto enable the Threads proposal (DefaultOFF). - Use
--enable-componentto enable the Component Model proposal (DefaultOFF, loader phase only). - Use
--enable-allto enable ALL proposals above.
- Use
- Input WASM file (
/path/to/wasm/file).
Example
Instantiating a self-contained module
We created the hand-written fibonacci.wat and used the wat2wasm tool to convert it into the fibonacci.wasm WebAssembly program. It exported a fib() function which takes a single i32 integer as the input parameter.
You can run:
wasmedge instantiate fibonacci.wasm
The output will be:
[2026-03-24 02:07:47.135] [info] Instantiation succeeded.
The exit code will be 0.
Instantiation failure due to unresolved imports
We created the hand-written bad_instantiate.wat and used the wat2wasm tool to convert it into the bad_instantiate.wasm WebAssembly program. This module imports functions, memory, tables, and globals from an env module that is not available in the CLI environment, causing instantiation to fail.
You can run:
wasmedge instantiate bad_instantiate.wasm
The output will be:
[2026-04-09 00:33:46.404] [error] instantiation failed: unknown import, Code: 0x302
[2026-04-09 00:33:46.404] [error] When linking module: "env" , memory name: "memory"
[2026-04-09 00:33:46.404] [error] At AST node: import description
[2026-04-09 00:33:46.404] [error] This may be the import of host environment like JavaScript or Golang. Please check that you've registered the necessary host modules from the host programming language.
[2026-04-09 00:33:46.404] [error] At AST node: import section
[2026-04-09 00:33:46.404] [error] At AST node: module
The exit code will be 1.
Multi-module linking
You can register additional WASM modules to satisfy imports using the --module option. For example, if main.wasm imports from a module named utils, you can provide it:
wasmedge instantiate --module utils:utils.wasm main.wasm
Multiple modules can be linked by repeating the --module flag:
wasmedge instantiate --module utils:utils.wasm --module math:math.wasm main.wasm
If all imports are resolved successfully, the output will be:
[info] Instantiation succeeded.