React pages (< PagesJS 1.0.0) - error when running "npm run build:serve"

Hi all,
I hope someone can help:
I’m following the React pages track and I can run it locally fine with “npm run dev” it generate the locator page as well as the individual location pages (see escreenshot)
ERROR: Error while building file "/Users/Andrea.Hurren/Shopify/jones-locator-live/localData/cog-internal-feature-static-file-generation-404__en__cfcd208495d565ef66e7dff9f98764da.json": plugin failed to generate page from document, encountered error: Error running plugin
The issue I have is when trying to run the production command “npm run build:serve” to check the prod build. I’ve pushed my github repo to yext and have a staging and production environment set. Any ideas what it could be?

Can you send a link to your site in platform?

@Duval_Kilpatrick, this is the production url: promptly-xeric-bedbug.pgsdemo.com
As you can see below, the build was successful in the platform but the pages were not generated. Its also giving an error

Error on Page Generation tab:

We are trying to replace our current store locator which it was built with an earlier version of the Pagebuilder.

Thanks for your help!

I’m looking for a link to what you show in the first screenshot, not a link to the actual website.

Sorry @Duval_Kilpatrick, I’m not sure I understand what you mean by “link to the site in the platform”? This is my company’s live account so I just don’t want to send any sensitive info.
I can send you a link to the github repo (the files i’m showing in the first screenshot) if that’s what you are asking?

Never mind, I found what I needed. If you look at the build tab you can see an error that YEXT_PUBLIC_GOOGLE_MAPS_API_KEY is undefined. I’m pretty sure that’s your issue. Try defining that and see if it changes anything. Though I am a little dubious since that’s used for the location page and you mentioned having an issue with the static page.

Another thing you can try if there’s still an issue is to update the version of @yext/pages in package.json since the one in your repo is quite old.

@Duval_Kilpatrick yep, it was indeed a wrong prop passed to a Banner component in one of the static files so after fixing that I’m now able to run npm run build:serve and it works.
I have added the google maps api key as well as you suggested and ran the production build, pushing the changes and running the deployment again.
I got a different error on the pages generation and realised I needed to add “en” as the locale in the stream configuration for location as well as the “savedFilterIds” and that seems to work so now the pages are generating OK in the platform.
Thanks again for your help!! :smile:

1 Like