Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.2.0で"Kuroshiro is not a constructor"のエラーが発生する #99

Open
ryudenx opened this issue Aug 18, 2022 · 2 comments
Open

Comments

@ryudenx
Copy link

ryudenx commented Aug 18, 2022

Version 1.2.0以降でKuroshiroを使用すると constructor ではないというエラーが発生します。

検証コード:

const Kuroshiro = require("kuroshiro");
const KuromojiAnalyzer = require("kuroshiro-analyzer-kuromoji");
const kuroshiro = new Kuroshiro();

kuroshiro.init(new KuromojiAnalyzer())
    .then(function(){
        return kuroshiro.convert("感じ取れたら手を繋ごう、重なるのは人生のライン and レミリア最高!", { to: "hiragana" });
    })
    .then(function(result){
        console.log(result);
    })

v1.1.2の出力:

かんじとれたらてをつなごう、かさなるのはじんせいのライン and レミリアさいこう!

v1.2.0の出力:

const kuroshiro = new Kuroshiro();
                  ^

TypeError: Kuroshiro is not a constructor

ご確認いただければ幸いです。

@halfsprit
Copy link

示例第一行代码是错误的,应该是
const Kuroshiro = require("kuroshiro").default;

@tokyohans
Copy link

tokyohans commented Nov 13, 2023

For those experiencing similar issues:

Update: The correct code for ES6 should be
import Kuroshiro from "kuroshiro"; const kuroshiro = new Kuroshiro.default();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants