Skip to content

The specified module could not be found. #1363

@tocha688

Description

@tocha688

System Info

The specified module could not be found.

Environment/Platform

  • Website/web-app
  • Browser extension
  • Server-side (e.g., Node.js, Deno, Bun)
  • Desktop app (e.g., Electron)
  • Other (e.g., VSCode extension)

Description


import { pipeline, env } from '@huggingface/transformers';

async function classifyImage() {
    const classifier = await pipeline('image-classification', 'Xenova/vit-base-patch16-224');

    const localImagePath = './img/ark/42d4f7ce-63ed-4c64-9883-037f4106ac27.jpg';
    const output = await classifier(localImagePath);
    if (output && output.length > 0) {
        output.forEach(result => {
            const scorePercent = (result.score * 100).toFixed(2);
            console.log(${result.label}  -  ${scorePercent}%`);
        });
    } else {
        console.log('null。');
    }
    console.log('------------------');
}

classifyImage().catch(console.error);
node:internal/modules/cjs/loader:1850
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: The specified module could not be found.
\\?\C:\Codes\nodejs\cc-test\node_modules\@huggingface\transformers\node_modules\onnxruntime-node\bin\napi-v3\win32\x64\onnxruntime_binding.node
    at Object..node (node:internal/modules/cjs/loader:1850:18)
    at Module.load (node:internal/modules/cjs/loader:1427:32)
    at Module._load (node:internal/modules/cjs/loader:1250:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
    at Module.require (node:internal/modules/cjs/loader:1449:12)
    at require (node:internal/modules/helpers:135:16)
    at Object.<anonymous> (C:\Codes\nodejs\cc-test\node_modules\@huggingface\transformers\node_modules\onnxruntime-node\dist\binding.js:10:1)
    at Module._compile (node:internal/modules/cjs/loader:1692:14)
    at Object..js (node:internal/modules/cjs/loader:1824:10) {
  code: 'ERR_DLOPEN_FAILED'
}

Node.js v24.4.0

Reproduction

I have tried @huggingface/transformers and @xenova/transformers, and both have the same problem. I reinstalled them using pnpm and npm, but the problem still exists.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions