Cursor agent terminal "npm run build"

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

When a cursor agent tries tor run “npm run build” for testing it alway yields:

[email protected] build
next build

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)

Version: 1.6.42
VSCode Version: 1.99.3
Commit: 5911e9593196a000b1c00553aaf03b0b32042b90
Date: 2025-09-20T17:16:56.346Z
Electron: 34.5.8
Chromium: 132.0.6834.210
Node.js: 20.19.1
V8: 13.2.152.41-electron.0
OS: Darwin arm64 25.0.0

Additional Information

the problem has appeared at least two or three updates ago and not just in the latest version.

Does this stop you from using Cursor

No - Cursor works, but with this issue

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
}

1 Like

Thanks for the info, that’s very helpful.

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