Skip to content

noConvexWrongRuntimeImports (JavaScript)

Language JavaScript (and super languages)
biome.json
{
"linter": {
"rules": {
"nursery": {
"noConvexWrongRuntimeImports": "error"
}
}
}
}

Disallow importing Node.js runtime files from Convex runtime files.

Files in your convex folder that start with "use node" run in Node.js. All other files run in the Convex runtime, which doesn’t support Node.js APIs. If a Convex runtime file imports a "use node" file, that code runs in the Convex runtime too, and can fail.

Move the shared code into a file without "use node", or add "use node" to the importing file if it only defines actions.

Type-only imports are allowed. Files that Convex doesn’t deploy as functions, such as schema.ts, test files, and files in _generated, are not checked.

convex/stripe.ts
"use node";
export function formatAmount(amount: number) {
return `$${amount.toFixed(2)}`;
}
convex/payments.ts
import { formatAmount } from "./stripe";
/convex/payments.ts:1:30 lint/nursery/noConvexWrongRuntimeImports ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ This file runs in the Convex runtime, but it imports ./stripe, which runs in Node.js.

> 1 │ import { formatAmount } from "./stripe";
│ ^^^^^^^^^^
2 │

ℹ Files with the "use node" directive run in Node.js. When you import one from a file without the directive, its code runs in the Convex runtime instead, where Node.js APIs aren't available.

ℹ Move the code you need into a file without the "use node" directive, or add the directive to this file if it only defines actions.

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

convex/format.ts
export function formatAmount(amount: number) {
return `$${amount.toFixed(2)}`;
}
convex/payments.ts
import { formatAmount } from "./format";