{"record":{"id":"f883e1ceb7e4c9a2","repo":"slidevjs/slidev","slug":"module-not-found-specifier-navailable-modules","errorCode":null,"errorMessage":"Module not found: ${specifier}.\\nAvailable modules: ${Object.keys(deps).join(', ')}. Please refer to https://sli.dev/custom/config-code-runners#additional-runner-dependencies","messagePattern":"Module not found: (.+?)\\.\\\\nAvailable modules: (.+?)\\. Please refer to https://sli\\.dev/custom/config-code-runners#additional-runner-dependencies","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/client/setup/code-runners.ts","lineNumber":86,"sourceCode":"  const onError = (error: any) => result.value.push({ error: String(error) })\n  const logger = (...objs: any[]) => result.value.push(objs.map(printObject))\n  const vmConsole = Object.assign({}, console)\n  vmConsole.info = vmConsole.log = vmConsole.debug = vmConsole.warn = vmConsole.error = logger\n  vmConsole.clear = () => result.value.length = 0\n  try {\n    const wrappedCode = `return async (console, __slidev_import, __slidev_on_error) => {\n    ${configs.monacoRunUseStrict ? `\"use strict\";` : ''}\n      try {\n        ${fixupCode(code)}\n      } catch (e) {\n        __slidev_on_error(e)\n      }\n    }`\n    // eslint-disable-next-line no-new-func\n    ;(new Function(wrappedCode)())(vmConsole, (specifier: string) => {\n      const mod = deps[specifier]\n      if (!mod)\n        throw new Error(`Module not found: ${specifier}.\\nAvailable modules: ${Object.keys(deps).join(', ')}. Please refer to https://sli.dev/custom/config-code-runners#additional-runner-dependencies`)\n      return mod\n    }, onError)\n  }\n  catch (error) {\n    onError(error)\n  }\n\n  function printObject(arg: any): CodeRunnerOutputText {\n    if (typeof arg === 'string') {\n      return {\n        text: arg,\n      }\n    }\n    return {\n      text: objectToText(arg),\n      highlightLang: 'javascript',\n    }\n  }","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/slidevjs/slidev/blob/0d798ace5828966d9f77f62094d5f7a971ad98f7/packages/client/setup/code-runners.ts#L68-L104","documentation":"Thrown inside the sandboxed JS/TS runner when user code calls __slidev_import('x') for a specifier that is not in the monacoRunDeps allow-list. Only modules explicitly registered as runner dependencies can be imported in the browser sandbox.","triggerScenarios":"Writing `import _ from 'lodash'` (or any specifier) in a runnable code block without registering lodash in monaco-run-deps.","commonSituations":"Assuming npm packages are auto-bundled into the client; locally-working imports that aren't shipped to the slide deck.","solutions":["Register the dependency in your code-runners config so it appears in #slidev/monaco-run-deps","Inline the needed logic in the snippet instead of importing","Bundle the dependency into a custom client module and register it under its specifier"],"exampleFix":"// before\nimport _ from 'lodash'\n// after - register in setup\nimport { defineApp } from '@slidev/types'\n// declare deps so the runner can resolve 'lodash'","handlingStrategy":"validation","validationCode":"const allowedSpecifiers = new Set(Object.keys(monacoRunDeps))\ncodeImports(specifier).forEach(s => {\n  if (!allowedSpecifiers.has(s)) throw new Error(`Unregistered import: ${s}`)\n})","typeGuard":"function isRegisteredDep(spec: string, deps: Record<string, unknown>): spec is string {\n  return spec in deps\n}","tryCatchPattern":null,"preventionTips":["Declare every import your runnable snippets use in monaco-run-deps","Static-scan snippets for import specifiers during build to catch missing deps"],"tags":["code-runner","import","sandbox","monaco"],"backgroundTag":null,"analyzedSha":"0d798ace5828966d9f77f62094d5f7a971ad98f7","analyzedAt":"2026-08-12T17:10:56.221Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}