Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation is wrong for initialising the plugin. #38606

Closed
2 tasks done
darylthornhill opened this issue Oct 3, 2023 · 4 comments · Fixed by #38816
Closed
2 tasks done

Documentation is wrong for initialising the plugin. #38606

darylthornhill opened this issue Oct 3, 2023 · 4 comments · Fixed by #38816
Labels
status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer type: documentation An issue or pull request for improving or updating Gatsby's documentation

Comments

@darylthornhill
Copy link

Preliminary Checks

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 darylthornhill added the type: documentation An issue or pull request for improving or updating Gatsby's documentation label Oct 3, 2023
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Oct 3, 2023
megascrapper added a commit to monash-human-power/MHP-website that referenced this issue Oct 8, 2023
rdela added a commit to rdela/rdela.com that referenced this issue Oct 14, 2023
…netlify (#648)

* Update dependency styled-components to v6

* add babel-plugin-styled-components

* rm gatsby-plugin-netlify, obviated by gatsby-adapter-netlify

* add gatsby-adapter-netlify to deps and config

* add gatsby-adapter-netlify with .default workaround for docs bug

see gatsbyjs/gatsby#38606

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Ricky de Laveaga <[email protected]>
@fturmel
Copy link

fturmel commented Oct 21, 2023

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

@RectoVersoDev
Copy link

RectoVersoDev commented Oct 27, 2023

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

JohanForngren added a commit to JohanForngren/gatsby-packages-gatsby-adapter-netlify-README.md that referenced this issue Jan 22, 2024
@JohanForngren
Copy link
Contributor

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

@logemann
Copy link

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

serhalp pushed a commit to JohanForngren/gatsby-packages-gatsby-adapter-netlify-README.md that referenced this issue Jun 25, 2024
serhalp pushed a commit to JohanForngren/gatsby-packages-gatsby-adapter-netlify-README.md that referenced this issue Jun 28, 2024
serhalp pushed a commit to JohanForngren/gatsby-packages-gatsby-adapter-netlify-README.md that referenced this issue Jun 28, 2024
serhalp pushed a commit to JohanForngren/gatsby-packages-gatsby-adapter-netlify-README.md that referenced this issue Jul 2, 2024
serhalp pushed a commit to JohanForngren/gatsby-packages-gatsby-adapter-netlify-README.md that referenced this issue Jul 30, 2024
serhalp pushed a commit that referenced this issue Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer type: documentation An issue or pull request for improving or updating Gatsby's documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants