• HOME
  • cheerioでのエラーについて
TomoyaOkada

cheerioでのエラーについて

記事をシェアする

事業用サイトのメディアに目次機能を追加しようと思い、cheerioをインストールしたのですが以下エラーが出てしまいました。

ERROR in ./node_modules/htmlparser2/lib/esm/index.js 59:9
Module parse failed: Unexpected token (59:9)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|     return getFeed(parseDOM(feed, options));
| }
> export * as DomUtils from "domutils";
| // Old name for DomHandler
| export { DomHandler as DefaultHandler };
 @ ./node_modules/cheerio/lib/esm/index.js 11:0-68
 @ ./node_modules/enzyme/build/ReactWrapper.js
 @ ./node_modules/enzyme/build/index.js
 @ ./test.entry.js



原因

エラー内容はローダーがないというエラー内容で、webpackに認識させるためのローダーを追加してくださいというものでした。
ですが現在はそれに対応しているローダーがない(?)らしいです。


解決策

下記をpackage.jsonに追加して、yarnで再度パッケージインストールを行なったらエラーがなくなりました。

    "cheerio": "1.0.0-rc.10",
    "parse5-htmlparser2-tree-adapter": "^6.0.0"



記事をシェアする