FlowiseAI/Flowise · critical · Error

Please install huggingface as a dependency with, e.g. `pnpm

Error message

Please install huggingface as a dependency with, e.g. `pnpm install @huggingface/inference`

What it means

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.

Source

Thrown at packages/components/nodes/chatmodels/ChatHuggingFace/core.ts:197

            !this.endpointUrl.includes('/v1/chat/completions') &&
            !this.endpointUrl.includes('router.huggingface.co')
        ) {
            return client.endpoint(this.endpointUrl)
        }

        // Return client without endpoint override - InferenceClient will use Inference Providers automatically
        return client
    }

    /** @ignore */
    static async imports(): Promise<{
        InferenceClient: typeof import('@huggingface/inference').InferenceClient
    }> {
        try {
            const { InferenceClient } = await import('@huggingface/inference')
            return { InferenceClient }
        } catch (e) {
            throw new Error('Please install huggingface as a dependency with, e.g. `pnpm install @huggingface/inference`')
        }
    }
}

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Run `pnpm install @huggingface/inference` (or npm/yarn equivalent) in the FlowiseComponents package and rebuild.
  2. Verify the installed version exports InferenceClient (v2.7+ of @huggingface/inference) — upgrade if older.
  3. Clear node_modules and the package manager store, then reinstall to fix a corrupt install.
  4. If building a Docker image, ensure the dependency is not pruned by a production-only install step.

Example fix

// before: import('@huggingface/inference') rejects

// after
// from the repository root or the components package
// pnpm
pnpm add @huggingface/inference
// npm
npm install @huggingface/inference
Defensive patterns

Strategy: validation

Validate before calling

async function ensureHuggingFaceInferenceInstalled() {
  try {
    await import('@huggingface/inference')
  } catch {
    throw new Error('Run `pnpm add @huggingface/inference` in the components package before using ChatHuggingFace.')
  }
}
await ensureHuggingFaceInferenceInstalled()

Type guard

async function hasInferenceClientExport(): Promise<boolean> {
  try {
    const mod = await import('@huggingface/inference')
    return typeof mod.InferenceClient === 'function'
  } catch {
    return false
  }
}

Try / catch

try {
  return await model.invoke(prompt)
} catch (e) {
  if (e.message.includes('install huggingface as a dependency')) {
    throw new Error('Missing dependency. Run `pnpm add @huggingface/inference` and restart Flowise.')
  }
  throw e
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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