{"record":{"id":"2c45ae7baf4fd539","repo":"FlowiseAI/Flowise","slug":"failed-to-load-fs-promises-make-sure-you-are-runn","errorCode":null,"errorMessage":"Failed to load fs/promises. Make sure you are running in Node.js environment.","messagePattern":"Failed to load fs/promises\\. Make sure you are running in Node\\.js environment\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/documentloaders/Json/Json.ts","lineNumber":313,"sourceCode":"                        ? { ...metadata, ...additionalMetadata }\n                        : {\n                              ...metadata,\n                              line: i + 1,\n                              ...additionalMetadata\n                          }\n            })\n        })\n    }\n\n    static async imports(): Promise<{\n        readFile: typeof ReadFileT\n    }> {\n        try {\n            const { readFile } = await import('node:fs/promises')\n            return { readFile }\n        } catch (e) {\n            console.error(e)\n            throw new Error(`Failed to load fs/promises. Make sure you are running in Node.js environment.`)\n        }\n    }\n}\n\nclass JSONLoader extends TextLoader {\n    public pointers: string[]\n    private metadataMapping: Record<string, string>\n    private separateByObject: boolean\n\n    constructor(\n        filePathOrBlob: string | Blob,\n        pointers: string | string[] = [],\n        metadataMapping: Record<string, string> = {},\n        separateByObject: boolean = false\n    ) {\n        super(filePathOrBlob)\n        this.pointers = Array.isArray(pointers) ? pointers : [pointers]\n        if (metadataMapping) {","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/documentloaders/Json/Json.ts#L295-L331","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","solutions":["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.","Mark node:fs/promises as external in your bundler config (webpack: externals, esbuild: --external:node:fs/promises).","Upgrade Node.js to a version supporting the node: scheme.","Use the Blob constructor branch by passing a Blob rather than a file path when in browser/edge."],"exampleFix":"// before - file path forces node:fs in a browser runtime\nnew JSONTextLoader('/data/file.json')\n// after - pass a Blob so node:fs/promises is never imported\nconst blob = new Blob([await file.arrayBuffer()], { type: 'application/json' })\nnew JSONTextLoader(blob)","handlingStrategy":"validation","validationCode":"// Detect Node availability before constructing a path-based loader\nfunction isNodeFsAvailable() {\n  try { require.resolve('node:fs/promises'); return true } catch { return false }\n}\nif (!isNodeFsAvailable() && typeof filePath === 'string') {\n  throw new Error('File-path input needs Node.js fs; pass a Blob in browser/edge runtimes')\n}","typeGuard":"function isBlob(v) { return typeof Blob !== 'undefined' && v instanceof Blob }","tryCatchPattern":"try {\n  return await textLoader.imports()\n} catch (e) {\n  if (/Failed to load fs\\/promises/.test(e.message)) {\n    throw new Error('Run in Node.js, or pass a Blob instead of a file path', { cause: e })\n  }\n  throw e\n}","preventionTips":["Pass a Blob instead of a file path in browser/edge runtimes.","Mark node:fs/promises as external in webpack/esbuild/rollup configs.","Run on Node.js >= 16.","Verify the runtime before passing file paths."],"tags":["node","runtime","bundler","fs","environment"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}