Environment
@runware/sdk version: > 1.3.4 (works with 1.3.4)
- Platform: Convex – serverless platform that bundles functions for either the V8 runtime or Node.js runtime (via
"use node" directive)
- Bundler: Convex’s internal bundler (based on esbuild)
Problem
When using @runware/sdk in a Convex project (outside a file marked with "use node"), the bundler fails with:
✘ [ERROR] Could not resolve "node:fs/promises"
node_modules/@runware/sdk/dist/index.js:2049:26:
2049 │ const fs = await import("node:fs/promises");
╵ ~~~~~~~~~~~~~~~~~~
The package "node:fs/promises" wasn't found on the file system but is built into node. Are
you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove
this error.
The SDK unconditionally imports node:fs/promises using a dynamic import(), which is not available in the default V8 runtime used by Convex (and many other bundlers that target non‑Node environments).
Expected behaviour
The SDK should work in any JavaScript environment (browser, V8, Node) without forcing the consumer to mark all using files with "use node" (Node.js runtime).
If Node.js‑specific modules are required, they should be conditionally loaded (e.g., try/catch or check for typeof process !== 'undefined'), or the SDK should provide separate entry points for Node.js and browser/V8.
Steps to reproduce
- Create a new Convex project (
bunx convex dev).
- Install
@runware/sdk version > 1.3.4 (e.g., 1.4.0).
- Import and call any function from the SDK inside a Convex query, mutation, or action without adding
"use node" at the top of the file.
- Run
bunx convex dev – the error appears.
Workaround (for users)
- Add
"use node" to the file that imports the SDK, which forces those functions to run in a Node.js runtime.
However, this forces the whole file (and all its imports) to be Node‑only, which may not be desirable if other parts of the file are V8‑optimised.
Suggested fix
- Replace the unconditional
await import("node:fs/promises") with a conditional import that only loads the module when running in a Node.js environment. For example:
let fs;
if (typeof process !== 'undefined' && process.versions?.node) {
fs = await import("node:fs/promises");
}
- Alternatively, use a try/catch around the import and fallback to a no‑op or throw a clear error if the functionality is required.
- Consider providing a browser‑compatible build (e.g., with
browser field in package.json) to avoid bundling Node‑specific code altogether.
Additional context
- Version
1.3.4 works fine in Convex without "use node".
- This issue affects any bundler or environment that does not support Node.js built‑ins, not just Convex.
Environment
@runware/sdkversion:> 1.3.4(works with1.3.4)"use node"directive)Problem
When using
@runware/sdkin a Convex project (outside a file marked with"use node"), the bundler fails with:The SDK unconditionally imports
node:fs/promisesusing a dynamicimport(), which is not available in the default V8 runtime used by Convex (and many other bundlers that target non‑Node environments).Expected behaviour
The SDK should work in any JavaScript environment (browser, V8, Node) without forcing the consumer to mark all using files with
"use node"(Node.js runtime).If Node.js‑specific modules are required, they should be conditionally loaded (e.g., try/catch or check for
typeof process !== 'undefined'), or the SDK should provide separate entry points for Node.js and browser/V8.Steps to reproduce
bunx convex dev).@runware/sdkversion> 1.3.4(e.g.,1.4.0)."use node"at the top of the file.bunx convex dev– the error appears.Workaround (for users)
"use node"to the file that imports the SDK, which forces those functions to run in a Node.js runtime.However, this forces the whole file (and all its imports) to be Node‑only, which may not be desirable if other parts of the file are V8‑optimised.
Suggested fix
await import("node:fs/promises")with a conditional import that only loads the module when running in a Node.js environment. For example:browserfield inpackage.json) to avoid bundling Node‑specific code altogether.Additional context
1.3.4works fine in Convex without"use node".