{"record":{"id":"453ea22d0d319c58","repo":"windmill-labs/windmill","slug":"unrecognized-import-i-path","errorCode":null,"errorMessage":"Unrecognized import: ${i.path}","messagePattern":"Unrecognized import: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"backend/windmill-worker/loader_builder.bun.js","lineNumber":43,"sourceCode":"}\n\nconst fs = require(\"fs/promises\");\n\nconst captureVersion =\n  /^((?:\\@[^\\/\\@]+\\/[^\\/\\@]+)|(?:[^\\/\\@]+))(?:\\@([^\\/]+))?.*$/;\n\nimport { semver } from \"bun\";\nimport { isBuiltin } from \"module\";\nlet content = await fs.readFile(\"./out/main.js\", { encoding: \"utf8\" });\nconst imports = new Bun.Transpiler().scanImports(\n  content.replaceAll(\"__require\", \"require\")\n);\n\nconst dependencies = {};\nfor (const i of imports) {\n  let [_, name, version] = i.path.match(captureVersion) ?? [];\n  if (name == undefined) {\n    throw Error(\"Unrecognized import: \" + i.path);\n  }\n  if (isBuiltin(name)) {\n    continue;\n  }\n  let splitted = name.split(\"/\");\n  if (splitted.length > 2) {\n    name = splitted.slice(0, 2).join(\"/\");\n  }\n  if (version == undefined) {\n    if (dependencies[name] == undefined) {\n      dependencies[name] = [];\n    }\n  } else {\n    if (dependencies[name] == undefined) {\n      dependencies[name] = [version];\n    } else if (!dependencies[name].includes(version)) {\n      dependencies[name].push(version);\n    }","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/windmill-worker/loader_builder.bun.js#L25-L61","documentation":"Windmill's dependency loader (loader_builder.bun.js) scans import statements of a script and parses each module path against a `captureVersion` regex to extract a package name and version. When an import path does not match the expected npm package specifier shape (no name/version captured), it throws this error while building the module loader.","triggerScenarios":"A TypeScript/JavaScript script imports a module whose path the regex can't parse: bare relative imports (`./util.ts`), absolute file imports, URLs, scoped-but-malformed specifiers, or an import with an unexpected version suffix form (e.g. `npm:pkg@`, or an alias like `pkg/` with empty segments that break the name split).","commonSituations":"Migrating a script between runtimes (Deno vs Bun) where relative/URL imports were allowed before; importing a local file instead of a published package in a serverless script; using npm aliases (`npm:foo@bar`) or non-npm URLs in an import statement; a typo such as `import x from \"@scope/\"`.","solutions":["Change the import to a valid npm package specifier with an explicit version, e.g. `import { z } from \"npm:zod@3.22.4\"` or `import dayjs from \"dayjs@1.11.10\"` depending on the runtime convention.","Remove or inline relative/local file imports — serverless scripts cannot load local modules; publish the code as a package or paste it inline.","Check the scoped package syntax: `@scope/name@version` (two path segments max); fix typos like trailing slashes or empty version (`pkg@`).","If using URLs or pre-bundled deps, move them to the platform's dependency settings (requirements/workspace dependencies) instead of the import line."],"exampleFix":"// before\nimport { helper } from \"./helpers.ts\";\n// after\nimport { helper } from \"npm:@mycompany/helpers@1.2.0\";","handlingStrategy":"validation","validationCode":"const captureVersion = /(?:npm:)?(@[^/]+\\/[^@\\s/]+|[^@\\s/]+)(?:@([^\\s]+))?/;\nfunction isRecognizableImport(spec) {\n  return captureVersion.test(spec) && !spec.startsWith('.') && !spec.startsWith('http');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Import only published npm packages with explicit versions in serverless scripts.","Never use relative (./) or absolute local file imports — inline the code or publish it.","Validate scoped package syntax (@scope/name@version) with no trailing slashes or empty versions.","When migrating scripts between runtimes (Deno/Bun), re-check every import specifier."],"tags":["imports","dependencies","bundler","windmill"],"backgroundTag":"unresolved-import-specifier","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}