windmill-labs/windmill · error · Error
Unrecognized import: ${i.path}
Error message
Unrecognized import: ${i.path} What it means
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.
Source
Thrown at backend/windmill-worker/loader_builder.bun.js:43
}
const fs = require("fs/promises");
const captureVersion =
/^((?:\@[^\/\@]+\/[^\/\@]+)|(?:[^\/\@]+))(?:\@([^\/]+))?.*$/;
import { semver } from "bun";
import { isBuiltin } from "module";
let content = await fs.readFile("./out/main.js", { encoding: "utf8" });
const imports = new Bun.Transpiler().scanImports(
content.replaceAll("__require", "require")
);
const dependencies = {};
for (const i of imports) {
let [_, name, version] = i.path.match(captureVersion) ?? [];
if (name == undefined) {
throw Error("Unrecognized import: " + i.path);
}
if (isBuiltin(name)) {
continue;
}
let splitted = name.split("/");
if (splitted.length > 2) {
name = splitted.slice(0, 2).join("/");
}
if (version == undefined) {
if (dependencies[name] == undefined) {
dependencies[name] = [];
}
} else {
if (dependencies[name] == undefined) {
dependencies[name] = [version];
} else if (!dependencies[name].includes(version)) {
dependencies[name].push(version);
}View on GitHub (pinned to e474e8803c)
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.
Example fix
// before
import { helper } from "./helpers.ts";
// after
import { helper } from "npm:@mycompany/helpers@1.2.0"; Defensive patterns
Strategy: validation
Validate before calling
const captureVersion = /(?:npm:)?(@[^/]+\/[^@\s/]+|[^@\s/]+)(?:@([^\s]+))?/;
function isRecognizableImport(spec) {
return captureVersion.test(spec) && !spec.startsWith('.') && !spec.startsWith('http');
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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/"`.
Related errors
- Failed to generate lockfile: ${message}
- bundle failed:\n${attempt.output}
- bundle produced no javascript:\n${buildOutput}
- no policy could be derived for runnable(s) ${malformed.join(
- result.substring(__ERR_PREFIX.length)
AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03).
Data as JSON: /api/errors/453ea22d0d319c58.
Report an issue: GitHub.