Build error occurred
[TypeError: generate is not a function]
when I run the same command from a terminal manually it builds without any issues. I think it appeared since agent-terminal became read-only but not sure.
Steps to Reproduce
Try running “npm rund build” by an agent.
Expected Behavior
actually run the build…
Operating System
MacOS
Current Cursor Version (Menu → About Cursor → Copy)
The issue is still here. I found out that cursor shell environment injects some vars that create the issue. When I ask cursor to unset the vars before executing the “npm run build” it works:
(unset __NEXT_PRIVATE_STANDALONE_CONFIG __NEXT_PRIVATE_ORIGIN NEXT_DEPLOYMENT_ID __NEXT_PRIVATE_RUNTIME_TYPE NEXT_OTEL_FETCH_DISABLED; npm run build)
Hey, thanks for the detailed investigation and finding the root cause. This definitely looks like a bug, Cursor’s agent terminal shouldn’t be injecting Next.js-specific environment variables that interfere with builds.
Your workaround is solid for now:
(unset __NEXT_PRIVATE_STANDALONE_CONFIG __NEXT_PRIVATE_ORIGIN NEXT_DEPLOYMENT_ID __NEXT_PRIVATE_RUNTIME_TYPE NEXT_OTEL_FETCH_DISABLED; npm run build)
I’ll pass this to the team so they can prevent these variables from leaking into the agent’s shell environment. Could you share what your next.config.js looks like (if you have any custom standalone configs)? That might help the team reproduce it.
In the meantime, if the read-only terminal is still causing issues, you can enable the legacy terminal tool here: Cursor Settings > Chat > Inline Editing & Terminal > Legacy Terminal Tool
Thanks for the quick reply! I just created a completely new simple next.js app project with minimal config and was able to reproduce the issue:
/** @type {import(‘next’).NextConfig} */
const nextConfig = {
reactStrictMode: true,
output: ‘standalone’, // For Docker deployment
}