{"record":{"id":"22ce059072d674ac","repo":"denoland/deno","slug":"err-invalid-arg-value-22ce05","errorCode":"ERR_INVALID_ARG_VALUE","errorMessage":"The property 'options.version' must be \"preview1\" or \"unstable\". Received ${options.version}","messagePattern":"The property 'options\\.version' must be \"preview1\" or \"unstable\"\\. Received (.+?)","errorType":"validation","errorClass":"ERR_INVALID_ARG_VALUE","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/wasi.ts","lineNumber":157,"sourceCode":"  #ctx;\n  #version: string;\n  #started = false;\n  #returnOnExit: boolean;\n  #wasiImport;\n\n  constructor(options?: WasiOptions) {\n    emitExperimentalWarning();\n    if (options === undefined) {\n      throw new ERR_INVALID_ARG_TYPE(\"options.version\", \"string\", undefined);\n    }\n    validateObject(options, \"options\");\n\n    if (options.version === undefined) {\n      throw new ERR_INVALID_ARG_TYPE(\"options.version\", \"string\", undefined);\n    }\n    validateString(options.version, \"options.version\");\n    if (options.version !== \"preview1\" && options.version !== \"unstable\") {\n      throw new ERR_INVALID_ARG_VALUE(\n        \"options.version\",\n        options.version,\n        'must be \"preview1\" or \"unstable\"',\n      );\n    }\n\n    const argsValue = options.args ?? [];\n    if (options.args !== undefined) {\n      validateArray(options.args, \"options.args\");\n    }\n    const args = ArrayPrototypeMap(argsValue, (arg) => String(arg));\n\n    const envObj = options.env ?? {};\n    if (options.env !== undefined) {\n      validateObject(options.env, \"options.env\");\n    }\n    const envPairs: [string, string][] = [];\n    for (const entry of new SafeArrayIterator(ObjectEntries(envObj))) {","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/node/polyfills/wasi.ts#L139-L175","documentation":"Thrown by the WASI constructor when options.version is present but is neither \"preview1\" nor \"unstable\". These two strings select the WASI snapshot (wasi_snapshot_preview1 vs wasi_unstable) that determines which import object the instance exposes. Any other value, including newer names like \"preview2\", is rejected.","triggerScenarios":"`new WASI({ version: \"preview2\" })` (WASI preview2 is a different API and not accepted here), `version: \"latest\"`, a typo like \"preivew1\", or a version string read from an env var / package.json that uses different naming.","commonSituations":"Assuming the Node WASI API supports WASI preview2 (it does not — preview2 is component-model based and served by separate runtimes); upgrading a toolchain that emits a different version string; sharing one config between a Wasmtime embedder and the Node API.","solutions":["Set `version: \"preview1\"` — this is the value virtually all command-line wasm modules built with wasi-sdk/clang --target=wasi32-wasi use.","If you need reactorthreaded modules documented as 'unstable', use `version: \"unstable\"`.","Do not feed preview2 component strings into this API; use a preview2-capable runtime or compile the module with the preview1 adapter instead."],"exampleFix":"// before\nconst wasi = new WASI({ version: \"preview2\" });\n\n// after\nconst wasi = new WASI({ version: \"preview1\" });","handlingStrategy":"validation","validationCode":"const VALID_WASI_VERSIONS = new Set(['preview1', 'unstable']);\nif (!VALID_WASI_VERSIONS.has(userVersion)) {\n  throw new Error(`Unsupported WASI version ${userVersion}; use \"preview1\"`);\n}","typeGuard":"function isWasiVersion(v: unknown): v is 'preview1' | 'unstable' {\n  return v === 'preview1' || v === 'unstable';\n}","tryCatchPattern":null,"preventionTips":["Treat the version as a closed union type 'preview1' | 'unstable', never a free-form string.","Remember node:wasi has no preview2 support; preview2 needs a different runtime."],"tags":["wasi","webassembly","node-compat","invalid-value","options-validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}