我刚刚将 gatsby-plugin-mdx 添加到我的 gatsby 插件中,但是当我启动项目时,我不断收到此错误。
Error in "/Gatsby/node_modules/gatsby-plugin-mdx/gatsby-node.js":
Cannot find module 'gatsby/webpack'
我确实注意到有一些版本警告,如下面的警告,但我不确定这是否是问题,因为只要 gatsby-plugin-mdx 未添加到 gatsby-config 中,它就可以工作。
我对 gatsby 很陌生,添加的大多数插件都是按照他们的教程来的,所以我真的在这里摸不着头脑。
任何想法是什么导致了这个以及如何解决它?
warn Plugin gatsby-plugin-sass is not compatible with your
gatsby version 3.14.6 - It requires gatsby@^4.0.0-next
这是我的 package.json
{
"name": "gatsby",
"version": "1.0.0",
"private": true,
"description": "Gatsby",
"author": "V",
"keywords": [
"gatsby"
],
"scripts": {
"develop": "gatsby develop",
"start": "gatsby develop",
"build": "gatsby build",
"serve": "gatsby serve",
"clean": "gatsby clean"
},
"dependencies": {
"@mdx-js/mdx": "^1.6.22",
"@mdx-js/react": "^1.6.22",
"@react-three/cannon": "^4.0.1",
"@react-three/drei": "^7.22.1",
"@react-three/fiber": "^7.0.19",
"classnames": "^2.3.1",
"dayjs": "^1.10.7",
"framer-motion": "^5.3.0",
"gatsby": "^3.12.1",
"gatsby-plugin-gatsby-cloud": "^3.0.0",
"gatsby-plugin-image": "^1.12.0",
"gatsby-plugin-layout": "^3.2.0",
"gatsby-plugin-mdx": "^3.3.0",
"gatsby-plugin-sass": "^5.1.1",
"gatsby-plugin-sharp": "^3.12.0",
"gatsby-source-filesystem": "^4.3.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"sass": "^1.43.4",
"three": "^0.134.0"
},
"devDependencies": {}
}
还有我的 gatsby-config.js
module.exports = {
siteMetadata: {
siteUrl: "https://www.yourdomain.tld",
title: "Gatsby",
},
plugins: [
"gatsby-plugin-gatsby-cloud",
"gatsby-plugin-image",
"gatsby-plugin-sharp",
`gatsby-plugin-sass`,
"gatsby-plugin-layout",
{
resolve: "gatsby-source-filesystem",
options: {
name: `src`,
path: `${__dirname}/src/works/`,
},
},
"gatsby-plugin-mdx" // adding this creates error!
],
};