gatsby build gives error || "Mailchimp endpoint required and must be of type string. "
Closed this issue · 10 comments
Hi everybody!
i implemented a subscription form in gatsby.when i run the server with "gatsby develop" everything works just fine.
but when i tried to build the website with "gatsby build" it gives error both on netlify and my computer.
ERROR DETAILS:
11:17:22 PM: error "gatsby-plugin-mailchimp" threw an error while running the onCreateWebpackConfig lifecycle:
11:17:22 PM: Mailchimp endpoint required and must be of type string. See repo README for more info.
11:17:22 PM: 10 |
11:17:22 PM: 11 | if (!isString) {
11:17:22 PM: > 12 | throw new Error(
11:17:22 PM: | ^
11:17:22 PM: 13 | 'Mailchimp endpoint required and must be of type string. See repo README for more info.',
11:17:22 PM: 14 | );
11:17:22 PM: 15 | } else if (endpoint.length < 40) {
11:17:22 PM:
11:17:22 PM:
11:17:22 PM: Error: Mailchimp endpoint required and must be of type string. See repo README for more info.
11:17:22 PM:
this is my configrutaion of gatsby-plugin-mailchimp , dotenv
gatsby-config.js:
require("dotenv").config({
path:.env.${process.env.NODE_ENV}
,
})
{
resolve: "gatsby-plugin-mailchimp",
options: {
endpoint: process.env.MAILCHIMP_ENDPOINT, // string
timeout: 3500,
},
},
i set MAILCHIMP_ENDPOINT in .env.development file.In netlify i also set environment variables with same value.
and MAILCHIMP_ENDPOINT is string.
if you have any ideas you can comment.any response will be appreciated.
btw thank you for this plugin.
please read the setup instructions in the README.
we discuss how to add your endpoint strong.
i read the setup insructions in the README and this time i didnt use dotenv i just passed the STRING to endpoint and it gives this error:
6:10:16 PM: failed Building static HTML for pages - 5.709s
6:10:16 PM: error Building static HTML failed
6:10:16 PM:
6:10:16 PM:
6:10:16 PM: WebpackError: /opt/build/repo/public/render-page.js:38648
6:10:16 PM:
6:10:16 PM: - build-html.js:107 doBuildPages
6:10:16 PM: [repo]/[gatsby]/dist/commands/build-html.js:107:24
6:10:16 PM:
6:10:16 PM: - build-html.js:121 async buildHTML
6:10:16 PM: [repo]/[gatsby]/dist/commands/build-html.js:121:3
6:10:16 PM:
6:10:16 PM: - build.js:219 async build
6:10:16 PM: [repo]/[gatsby]/dist/commands/build.js:219:5
6:10:16 PM:
6:10:16 PM:
6:10:16 PM: not finished Generating image thumbnails - 43.155s
6:10:16 PM:
6:10:16 PM: ┌─────────────────────────────┐
6:10:16 PM: │ "build.command" failed │
6:10:16 PM: └─────────────────────────────┘
6:10:16 PM:
6:10:16 PM: Error message
6:10:16 PM: Command failed with exit code 1: gatsby build
6:10:16 PM:
6:10:16 PM: Error location
6:10:16 PM: In Build command from settings:
6:10:16 PM: gatsby build
6:10:16 PM:
6:10:16 PM: Resolved config
6:10:16 PM: build:
6:10:16 PM: command: gatsby build
6:10:16 PM: publish: /opt/build/repo/public
dooes your gatsby-config
looks like this:
{
resolve: 'gatsby-plugin-mailchimp',
options: {
endpoint: '', // string; add your MC list endpoint here; see instructions below
timeout: 3500, // number; the amount of time, in milliseconds, that you want to allow mailchimp to respond to your request before timing out. defaults to 3500
},
},
please share yours
that error you show does not indicate that the error is related to this plugin... can you be extra sure you don't have any other changes in your diff.
try starting from scratch. and install this plugin. read the entire README first.. hope that works!
i just unintsalled this plugin from my project and tried to build again with gatsby build. and successfully builded.
i think this plugin causes the problem .you should really check it
im sure this plugin did cause the issue. no doubt. but it's hard to diagnose without knowing more about your setup. as required above, what does your gatsby-config
look like, specifically for this plugin section? what other changes have you made? what other plugins have you installed.
it's really hard to know where to look without knowing more about your individual setup.
im going to close this ticket for now but okay with re-opening it if you'd like to work together to figure out what's wrong.
thanks!
Hey @benjaminhoffman I'm having the same issue (Mailchimp Endpoint required OR must be of type string).. to allow it to build for now, I modified the plugin to not check for a string (was meeting a client deadline and didnt have time to troubleshoot), here's my set up:
},
{
resolve: 'gatsby-plugin-mailchimp',
options: {
endpoint: '{string added here starting with https://listname.us16.list-manage.com etc}', // string; add your MC list endpoint here; see instructions below
timeout: 3500, // number; the amount of time, in milliseconds, that you want to allow mailchimp to respond to your request before timing out. defaults to 3500
},
},
Here's my exact error (for now it's the Endpoint required one):
Error: gatsby-plugin-mailchimp: donʼt forget to add your MC endpoint to your gatsby- config file. See README for more info.
Fixed my own problem, for people with the same problem: make sure your endpoint copy-paste DOESN'T convert the "&" to "&", fixing that made it run seamlessly, thanks @benjaminhoffman for the lovely plugin!!
Hi. I had the same error on Netlify build. What I did - added Mailchimp endpoint to Netlify Build Variables. Read more: https://docs.netlify.com/configure-builds/environment-variables/
Hope it helps.
For those who hit this error and aren't using environment variables handled by netlify but through .env files I have a potential solution.
Spent a lot of time headscratching until I realised that my mailchimp endpoint was only contained in .env.development
and not in .env.production
as well. Adding it to that will make sure gatsby build
runs correctly.