Skip to content

Gatsby Source Plugin

DodaTech 1 min read

In this tutorial, you'll learn about Gatsby Source Plugin Error Fix. We cover key concepts, practical examples, and best practices.

The Problem

Error: "gatsby-source-filesystem" — the plugin is not configured.
No nodes created from the source plugin. Check your gatsby-config.js.

Gatsby source plugins need configuration to specify which data to fetch.

Wrong

// gatsby-config.js
module.exports = {
  plugins: ['gatsby-source-filesystem']
}

Output: no filesystem nodes created. The plugin runs but has no options telling it which directory to source.

module.exports = {
  plugins: [
    {
      resolve: 'gatsby-source-filesystem',
      options: {
        name: 'posts',
        path: `${__dirname}/content/posts`,
      },
    },
  ],
}

Output: GraphQL nodes are created for all files in content/posts/.

Prevention

  • Always provide options with path for gatsby-source-filesystem
  • Use name to label different source instances
  • Check GraphiQL at http://localhost:8000/___<a href="/apis/graphql/">Graphql</a> to verify nodes exist

Common Mistakes with source plugin

  1. Mixing let bindings with <- bindings in do notation, producing type errors
  2. Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors
  3. Non-exhaustive pattern matches that compile with warnings then crash at runtime

These mistakes appear frequently in real-world GATSBY code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### How do I source data from multiple directories?

Add multiple instances of the source plugin with different names and paths. Each instance creates a separate set of nodes identifiable by the name option.

Why does my Gatsby source plugin create no nodes?

The plugin may not be installed, the path may be incorrect, or the directory may be empty. Verify the path exists and contains files with extensions Gatsby recognizes.

What is the difference between a source plugin and a transformer plugin?

Source plugins fetch data into Gatsby's node system (e.g. filesystem, CMS). Transformer plugins convert raw data into usable formats (e.g. Markdown to HTML).

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro