{"record":{"id":"ab10d1ccd7df8b4c","repo":"FlowiseAI/Flowise","slug":"please-install-huggingface-as-a-dependency-with-e","errorCode":null,"errorMessage":"Please install huggingface as a dependency with, e.g. `pnpm install @huggingface/inference`","messagePattern":"Please install huggingface as a dependency with, e\\.g\\. `pnpm install @huggingface/inference`","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/components/nodes/chatmodels/ChatHuggingFace/core.ts","lineNumber":197,"sourceCode":"            !this.endpointUrl.includes('/v1/chat/completions') &&\n            !this.endpointUrl.includes('router.huggingface.co')\n        ) {\n            return client.endpoint(this.endpointUrl)\n        }\n\n        // Return client without endpoint override - InferenceClient will use Inference Providers automatically\n        return client\n    }\n\n    /** @ignore */\n    static async imports(): Promise<{\n        InferenceClient: typeof import('@huggingface/inference').InferenceClient\n    }> {\n        try {\n            const { InferenceClient } = await import('@huggingface/inference')\n            return { InferenceClient }\n        } catch (e) {\n            throw new Error('Please install huggingface as a dependency with, e.g. `pnpm install @huggingface/inference`')\n        }\n    }\n}\n","sourceCodeStart":179,"sourceCodeEnd":201,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/chatmodels/ChatHuggingFace/core.ts#L179-L201","documentation":"ChatHuggingFace.core dynamically imports @huggingface/inference (specifically InferenceClient) via import('@huggingface/inference'). If that dynamic import throws — typically because the package is not installed — Flowise surfaces a friendly install instruction. This is a dependency-resolution failure, not a runtime API failure.","triggerScenarios":"The @huggingface/inference npm package is absent from node_modules, has a corrupt install, or is the wrong version that does not export InferenceClient. The dynamic import() promise rejects and the catch re-throws the install hint.","commonSituations":"Custom Flowise build where the optional peer dependency was pruned; monorepo hoisting removed the package; partial/cancelled pnpm install; running against an older FlowiseComponents that predates the InferenceClient rename; Docker image built without the dependency.","solutions":["Run `pnpm install @huggingface/inference` (or npm/yarn equivalent) in the FlowiseComponents package and rebuild.","Verify the installed version exports InferenceClient (v2.7+ of @huggingface/inference) — upgrade if older.","Clear node_modules and the package manager store, then reinstall to fix a corrupt install.","If building a Docker image, ensure the dependency is not pruned by a production-only install step."],"exampleFix":"// before: import('@huggingface/inference') rejects\n\n// after\n// from the repository root or the components package\n// pnpm\npnpm add @huggingface/inference\n// npm\nnpm install @huggingface/inference","handlingStrategy":"validation","validationCode":"async function ensureHuggingFaceInferenceInstalled() {\n  try {\n    await import('@huggingface/inference')\n  } catch {\n    throw new Error('Run `pnpm add @huggingface/inference` in the components package before using ChatHuggingFace.')\n  }\n}\nawait ensureHuggingFaceInferenceInstalled()","typeGuard":"async function hasInferenceClientExport(): Promise<boolean> {\n  try {\n    const mod = await import('@huggingface/inference')\n    return typeof mod.InferenceClient === 'function'\n  } catch {\n    return false\n  }\n}","tryCatchPattern":"try {\n  return await model.invoke(prompt)\n} catch (e) {\n  if (e.message.includes('install huggingface as a dependency')) {\n    throw new Error('Missing dependency. Run `pnpm add @huggingface/inference` and restart Flowise.')\n  }\n  throw e\n}","preventionTips":["Add @huggingface/inference as an explicit dependency in package.json.","Pin a version that exports InferenceClient (>=2.7).","Include a startup probe that imports the package and fails fast if missing.","Rebuild Docker images after dependency changes; do not prune optional deps."],"tags":["huggingface","dependency","import","installation","peer-dependency"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}