https://www.boundaryml.com logo
Build errors in NextJS web app
# help
m
I keep running into build errors trying to deploy my nextjs app on AWS Amplify. FWIW had similar issues trying to deploy a lambda function calling a BAML function, fixed it by messing around with the packag.json. Build is fine locally, just failing on staging / prod. Here's a sample of the error: https://cdn.discordapp.com/attachments/1421624181363314821/1421624181514047609/Screenshot_2025-09-27_at_3.26.53_PM.png?ex=68d9b631&is=68d864b1&hm=b9e7006355674806ef2b1fb06db8a534254ea4db2c80583898010ed1910fe10a&
a
can you paste your nextjs.config?
you can try adding this:
Copy code
import { withBaml } from '@boundaryml/baml-nextjs-plugin';

/** @type {import('next').NextConfig} */
const nextConfig = {
  webpack: (config, { dev, isServer, webpack, nextRuntime }) => {
    .......

    return config;
  },
};

export default withBaml()(nextConfig);
oh one more thing -- what architecture/platform do you deploy onto in amplify? Is it an amazon linux machine? arm64 or x86? Do you deploy within some docker container, and if so, what image do you use?
a
what version is the @boundaryml / baml package in your package.json?
m
0.207.0
a
hmm lets try simplifying your webpack config block. Try removing the withBaml(), and just add this directly: ``` const nextConfig = { serverExternalPackages: ["@boundaryml/baml"], webpack: (config, { dev, isServer, webpack, nextRuntime }) => { config.module.rules.push({ test: /\.node$/, use: [ { loader: "nextjs-node-loader", options: { outputPath: config.output.path, }, }, ], }); return config; }, }; export default nextConfig;
and one more thing -- do you use Turbo?
next build --turbo
m
yes
a
ok one sec we do have a PR open to fix turbo which you can try now as well by copying the code
oh but it seems that in production, it doesn't use turbo right? if you're not sure that's ok
you can first try the changes above ^^ in production
i can also hop on a call if needed -- how long does it take to deploy AWS Amplify? just curious
m
i think it worked!!
a
oh snap
did it??
m
yes! tysm
a
Sweeet, sorry for the snags. Deploying is the hardesr part
if you have issues with turbo this helper function may work, it's just that i think what happened is that you use turbo locally and perhaps amplify isn't, and our withBaml script is bugged and doesnt add that node loader for non-turbo