node-mecab-async icon indicating copy to clipboard operation
node-mecab-async copied to clipboard

new mecab returning empty object

Open AmodeusR opened this issue 2 years ago • 5 comments

I was trying to utilize this library but when I instanciated MeCab it only returned an empty object, What's up with the library? Isn't it working anymore?

Here's a example: https://replit.com/@AmodeusR/Mecab-library-test

AmodeusR avatar Feb 27 '23 01:02 AmodeusR

same issue +1

crokobit avatar Oct 11 '24 02:10 crokobit

I apologize for the delayed response.

It’s possible that mecab-ipadic is not installed. Could you check on the console if the regular mecab command returns results correctly?

hecomi avatar Jan 01 '25 06:01 hecomi

I don't even remember exactly what was the problem, but at least trying it now, it throws an error saying mecab was not found. How do I get it?

Error: Command failed: echo これがただの簡単な日本語の文ですよ | mecab
/bin/sh: 1: mecab: not found

    at genericNodeError (node:internal/errors:984:15)
    at wrappedFn (node:internal/errors:538:14)
    at ChildProcess.exithandler (node:child_process:422:12)
    at ChildProcess.emit (node:events:518:28)
    at maybeClose (node:internal/child_process:1104:16)
    at Socket.<anonymous> (node:internal/child_process:456:11)
    at Socket.emit (node:events:518:28)
    at Pipe.<anonymous> (node:net:343:12) {
  code: 127,
  killed: false,
  signal: null,
  cmd: 'echo これがただの簡単な日本語の文ですよ | mecab'
}

AmodeusR avatar Jan 06 '25 11:01 AmodeusR

Thank you for the information. The error seems to come from the MeCab command not being accessible. Please install MeCab according to your OS (e.g., on macOS: brew install mecab and brew install mecab-ipadic) and ensure the path is set. If you’d rather not set the path globally, you can specify it directly in your code:

var MeCab = new require('mecab-async');
var mecab = new MeCab();
mecab.command = '/usr/local/bin/mecab';

hecomi avatar Jan 07 '25 01:01 hecomi

Thank you for the information. The error seems to come from the MeCab command not being accessible. Please install MeCab according to your OS (e.g., on macOS: brew install mecab and brew install mecab-ipadic) and ensure the path is set. If you’d rather not set the path globally, you can specify it directly in your code:

Where can I download it for Windows? I tried going to Taku's MeCab website but the link is broken.

AmodeusR avatar Jan 08 '25 12:01 AmodeusR