gatsby icon indicating copy to clipboard operation
gatsby copied to clipboard

Documentation is wrong for initialising the plugin.

Open darylthornhill opened this issue 1 year ago • 4 comments

Preliminary Checks

  • [X] This issue is not a duplicate. Before opening a new issue, please search existing issues: https://github.com/gatsbyjs/gatsby/issues
  • [X] This issue is not a question, feature request, RFC, or anything other than a bug report. Please post those things in GitHub Discussions: https://github.com/gatsbyjs/gatsby/discussions

Summary

When including the code as per the docs it actually errors saying adapter is not a function.

const adapter = require('gatsby-adapter-netlify');

module.exports = {
    adapter: adapter({
        excludeDatastoreFromEngineFunction: false,
    }),
}

Im assuming this is because if you import it will grab the .default manually

Steps to Resolve this Issue

  1. use import instead
  2. add .default at the end of require

darylthornhill avatar Oct 03 '23 12:10 darylthornhill

Same issue with import and an esm gatsby-config.mjs file (supported since Gatsby 5.3).

I tried import adapter from 'gatsby-adapter-netlify'; and import { default as adapter } from 'gatsby-adapter-netlify'; but get the following error:

ERROR #10123  API.CONFIG.LOADING

We encountered an error while trying to load your site's gatsby-config. Please fix the error and try again.

TypeError: adapter is not a function
  
  - gatsby-config.mjs:13 
    {project-path}/gatsby-config.mjs:13:12
  
  - module_job:194 ModuleJob.run
    node:internal/modules/esm/module_job:194:25

fturmel avatar Oct 21 '23 14:10 fturmel

Same issue here, can't make it work with gatsby 5.12.9

error We encountered an error while trying to load your site"s gatsby-config. Please fix the error and try again.
TypeError: adapter is not a function

RectoVersoDev avatar Oct 27 '23 08:10 RectoVersoDev

const adapter = require("gatsby-adapter-netlify").default as @darylthornhill suggested is propsed in PR #38816

JohanForngren avatar Jan 22 '24 12:01 JohanForngren

Is there any reason why this isnt fixed in the docs? Annoying to search around for basic things like that....

logemann avatar May 22 '24 10:05 logemann