我试图遵循有关包含 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")
]
}
}
],
};Run Code Online (Sandbox Code Playgroud)
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。即使使用全新的网站,问题仍然存在。任何有关此问题的帮助将不胜感激。