{"record":{"id":"57edbcda09d4d770","repo":"FlowiseAI/Flowise","slug":"please-install-huggingface-as-a-dependency-with-e-57edbc","errorCode":null,"errorMessage":"Please install huggingface as a dependency with, e.g. `pnpm add @huggingface/inference`","messagePattern":"Please install huggingface as a dependency with, e\\.g\\. `pnpm add @huggingface/inference`","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/llms/HuggingFaceInference/core.ts","lineNumber":110,"sourceCode":"            },\n            inputs: prompt\n        }\n        if (!this.endpoint) {\n            obj.model = this.model\n        }\n        const res = await this.caller.callWithOptions({ signal: options.signal }, hfClient.textGeneration.bind(hfClient), obj)\n        return res.generated_text\n    }\n\n    /** @ignore */\n    static async imports(): Promise<{\n        HfInference: typeof import('@huggingface/inference').HfInference\n    }> {\n        try {\n            const { HfInference } = await import('@huggingface/inference')\n            return { HfInference }\n        } catch (e) {\n            throw new Error('Please install huggingface as a dependency with, e.g. `pnpm add @huggingface/inference`')\n        }\n    }\n}\n","sourceCodeStart":92,"sourceCodeEnd":114,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/llms/HuggingFaceInference/core.ts#L92-L114","documentation":"The static imports() method dynamically imports @huggingface/inference; if the module cannot be resolved it re-throws with this install hint. This is a runtime dependency-resolution failure, not a network error.","triggerScenarios":"First _call() to the HuggingFaceInference node triggers imports(); the @huggingface/inference package is absent from node_modules in the running deployment.","commonSituations":"Custom/trimmed Flowise build that omitted the optional dependency; production image built without install of the components package deps; monorepo hoisting removed the package; package renamed/removed.","solutions":["Install the package in the components workspace: pnpm add @huggingface/inference.","Rebuild/redeploy the image so node_modules includes the package.","Confirm it resolves at runtime: node -e \"require.resolve('@huggingface/inference')\"."],"exampleFix":"// before: @huggingface/inference missing from package.json\n// after\npnpm --filter flowise-components add @huggingface/inference","handlingStrategy":"validation","validationCode":"// Fail fast at boot if the optional dependency is missing\ntry { require.resolve('@huggingface/inference') }\ncatch { throw new Error('Run: pnpm add @huggingface/inference before using HuggingFaceInference') }","typeGuard":"async function huggingfaceAvailable(): Promise<boolean> {\n  try { await import('@huggingface/inference'); return true } catch { return false }\n}","tryCatchPattern":"try {\n  const { HfInference } = await import('@huggingface/inference')\n} catch {\n  // degrade gracefully or instruct the user to install the dependency\n  throw new Error('Install @huggingface/inference to use this node')\n}","preventionTips":["Declare @huggingface/inference in the components package.json dependencies.","Run require.resolve checks in a boot smoke test.","Rebuild production images after adding the dependency.","Verify optional deps are not tree-shaken out of the bundle."],"tags":["huggingface","dependency","install","runtime","module-resolution"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}