【发布时间】:2021-11-08 23:16:04
【问题描述】:
我正在尝试关注documentation 包括 gatsby-plugin-mdx 的 rehype 插件。具体来说,我试图使用rehype-slug 插件。我安装了 npm 打包并将我的gatsby.config.js 文件设置为
module.exports = {
siteMetadata: {
siteUrl: "https://www.yourdomain.tld",
title: "test Website",
},
plugins: [
{
resolve: "gatsby-plugin-mdx",
options:{
rehypePlugins: [
require("rehype-slug")
]
}
}
],
};
gatsby develop 时,我遇到了以下错误:
Error: [ERR_REQUIRE_ESM]: Must use import to load ES Module: C:\Users\User\Documents\test-site\node_modules\rehype-slug\index.js require() of ES modules is not supported.
我在尝试使用 remark-math 和 rehype-katex 插件时遇到了类似的问题。我正在使用 Gatsby CLI 的 3.13.0 版本。即使使用全新的网站,问题仍然存在。对此问题的任何帮助将不胜感激。
【问题讨论】:
-
在 gatsby 解决 esm 问题之前,将 rehype-slug 降级到 4.0.1 使其工作。
标签: gatsby remarkjs gatsby-plugin-mdx