Build Failed: Error: std::bad_alloc

Gatsby build on localhost worked great, but the build failed when I pushed to Render.

Package Current Wanted Latest Location Depended by
gatsby-plugin-sharp 2.14.4 2.14.4 4.13.0 gatsby-plugin-sharp id
react 17.0.2 17.0.2 18.1.0 node_modules/react id
react-dom 17.0.2 17.0.2 18.1.0 node_modules/react-dom id

Text from failed event:

May 7 07:47:11 PM ==> Downloading cache…
May 7 07:47:43 PM ==> Downloaded 457MB in 10s. Extraction took 19s.
May 7 07:47:49 PM ==> Installing dependencies with npm…
May 7 07:48:30 PM removed 140 packages and audited 3469 packages in 39.667s
May 7 07:48:32 PM
May 7 07:48:32 PM 248 packages are looking for funding
May 7 07:48:32 PM run npm fund for details
May 7 07:48:32 PM
May 7 07:48:32 PM found 200 vulnerabilities (42 low, 51 moderate, 87 high, 20 critical)
May 7 07:48:32 PM run npm audit fix to fix them, or npm audit for details
May 7 07:49:05 PM audited 3469 packages in 31.77s
May 7 07:49:08 PM
May 7 07:49:08 PM 248 packages are looking for funding
May 7 07:49:08 PM run npm fund for details
May 7 07:49:08 PM
May 7 07:49:08 PM found 200 vulnerabilities (42 low, 51 moderate, 87 high, 20 critical)
May 7 07:49:08 PM run npm audit fix to fix them, or npm audit for details
May 7 07:49:19 PM ==> Using Python version: 3.7.10
May 7 07:49:24 PM ==> Running build command ‘gatsby build’…
May 7 07:49:28 PM
May 7 07:49:28 PM ERROR #11903 COMPILATION
May 7 07:49:28 PM
May 7 07:49:28 PM There was an unhandled error during compilation for /opt/render/project/src.
May 7 07:49:28 PM Please run the command with the --verbose flag again.
May 7 07:49:28 PM

May 7 07:49:28 PM
May 7 07:49:28 PM Error: std::bad_alloc
May 7 07:49:28 PM
not finished compile gatsby files - 0.313s
May 7 07:49:28 PM
May 7 07:49:28 PM ==> Build failed :disappointed:

Hi there,

Thanks for reaching out.

Searching for the error ERROR # 11903 COMPILATION in relation to Gatsby seems to have some suggestions around issues of Node version/packages and file/node_module issues.

Your repo appears to be public and that node_modules & .cache directories are present, as a starting point I’d suggest:

  • Add a .gitignore to the project to remove node_modules & .cache. StackOverflow on adding a .gitignore to remove node_modules.

  • Define your local Node version in your package.json to ensure you’re running on the same version locally & on Render. More on defining Node versions (option 4 is the package.json definition)

  • Redeploy

Hope that helps

Alan

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.