【问题标题】:Gatsby Error: TypeError [ ERR_INVALID_ARG_TYPE]盖茨比错误:TypeError [ERR_INVALID_ARG_TYPE]
【发布时间】:2020-12-03 10:15:36
【问题描述】:

我正在关注 Andrew Mead 关于 Gatsby Bootcamp 的 youtube 教程,时间最长为 3:10:00 一切都很顺利,但是当我安装 gatsby-remark-relative-imagesgatsby-remark-images 插件并将它们添加到 gatsby-config.js 文件以显示图像时,当我运行 npm run develop 时,我会收到如下所示的错误。

下面是我的 gatsby-config.js 文件。

/**
 * Configure your Gatsby site with this file.
 *
 * See: https://www.gatsbyjs.org/docs/gatsby-config/
 */

module.exports = {
  /* Your site config here */

  siteMetadata:{
    title:'Gatsby Bootcamp',
    author:'Author'
  },
  plugins: [
    'gatsby-plugin-sass',
    {
      resolve:'gatsby-source-filesystem',
      options:{
        name: 'src',
        path: `${__dirname}/src/`
      }
    },
    'gatsby-plugin-sharp',
    {
      reslove: 'gatsby-transformer-remark',
      options:{
        plugins:[
          'gatsby-remark-relative-images',
          {
            resolve:'gatsby-remark-images',
            options:{
              maxWidth:750,
              linkImagesToOriginal: false
            }
          }
        ]
      }
    }
  ]
}

请帮忙!提前谢谢你。

【问题讨论】:

    标签: gatsby gatsby-image gatsby-plugin gatsby-remark-image


    【解决方案1】:

    作为documentation explains,您必须在gatsby-node.js 中添加以下sn-p:

    const { fmImagesToRelative } = require('gatsby-remark-relative-images');
    
    exports.onCreateNode = ({ node }) => {
      fmImagesToRelative(node);
    };
    

    如果找到匹配的文件,这会获取 gatsby-source 插件返回的每个节点,并将 markdown frontmatter 数据中的任何绝对路径转换为相对路径。

    【讨论】:

    • 感谢您的帮助。我也有一个简单的拼写错误。我没有决心,而是有决心。现在可以正常使用了。
    猜你喜欢
    • 2020-05-27
    • 1970-01-01
    • 2022-01-10
    • 2020-10-16
    • 2019-08-07
    • 2021-12-14
    • 2022-08-19
    • 2021-07-30
    • 2020-12-02
    相关资源
    最近更新 更多