FlowiseAI/Flowise · error · Error

Failed to load fs/promises. Make sure you are running in Nod

Error message

Failed to load fs/promises. Make sure you are running in Node.js environment.

What it means

Thrown by TextLoader.imports() in Json.ts when the dynamic import('node:fs/promises') rejects. readFile is only needed for the string file-path branch of load(), so this is a runtime-environment error: the Node.js built-in fs module could not be loaded.

Source

Thrown at packages/components/nodes/documentloaders/Json/Json.ts:313

                        ? { ...metadata, ...additionalMetadata }
                        : {
                              ...metadata,
                              line: i + 1,
                              ...additionalMetadata
                          }
            })
        })
    }

    static async imports(): Promise<{
        readFile: typeof ReadFileT
    }> {
        try {
            const { readFile } = await import('node:fs/promises')
            return { readFile }
        } catch (e) {
            console.error(e)
            throw new Error(`Failed to load fs/promises. Make sure you are running in Node.js environment.`)
        }
    }
}

class JSONLoader extends TextLoader {
    public pointers: string[]
    private metadataMapping: Record<string, string>
    private separateByObject: boolean

    constructor(
        filePathOrBlob: string | Blob,
        pointers: string | string[] = [],
        metadataMapping: Record<string, string> = {},
        separateByObject: boolean = false
    ) {
        super(filePathOrBlob)
        this.pointers = Array.isArray(pointers) ? pointers : [pointers]
        if (metadataMapping) {

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Run in a Node.js runtime (>= 16) where node:fs/promises is available — pass a Blob instead of a file path for non-Node environments.
  2. Mark node:fs/promises as external in your bundler config (webpack: externals, esbuild: --external:node:fs/promises).
  3. Upgrade Node.js to a version supporting the node: scheme.
  4. Use the Blob constructor branch by passing a Blob rather than a file path when in browser/edge.

Example fix

// before - file path forces node:fs in a browser runtime
new JSONTextLoader('/data/file.json')
// after - pass a Blob so node:fs/promises is never imported
const blob = new Blob([await file.arrayBuffer()], { type: 'application/json' })
new JSONTextLoader(blob)
Defensive patterns

Strategy: validation

Validate before calling

// Detect Node availability before constructing a path-based loader
function isNodeFsAvailable() {
  try { require.resolve('node:fs/promises'); return true } catch { return false }
}
if (!isNodeFsAvailable() && typeof filePath === 'string') {
  throw new Error('File-path input needs Node.js fs; pass a Blob in browser/edge runtimes')
}

Type guard

function isBlob(v) { return typeof Blob !== 'undefined' && v instanceof Blob }

Try / catch

try {
  return await textLoader.imports()
} catch (e) {
  if (/Failed to load fs\/promises/.test(e.message)) {
    throw new Error('Run in Node.js, or pass a Blob instead of a file path', { cause: e })
  }
  throw e
}

Prevention

When it happens

Trigger: Running the loader in a browser/edge worker where node:fs/promises does not exist; a bundler (webpack/rollup) that fails to mark node:fs/promises as external and tries to bundle it; a corrupted or misconfigured Node.js install; ESM/CJS interop issue dropping the node: scheme.

Common situations: Deploying the loader into a serverless browser runtime; bundling with a config that polyfills fs incorrectly; running on an old Node version where the node: prefix is unsupported (< 16).

Related errors


AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12). Data as JSON: /api/errors/2c45ae7baf4fd539. Report an issue: GitHub.