[BUG] NODE_ENV=development from VSCode extension pollutes shell environment causing Next.js build failures

Resolved 💬 4 comments Opened Oct 21, 2025 by jmsaavedra Closed Jan 8, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

The Claude Code VSCode extension sets NODE_ENV=development in all shell environments, which causes Next.js (and potentially other Node.js build tools) to fail with build errors that don't occur in a normal terminal.

When running npm run build through Claude Code in VSCode, Next.js shows:

  1. Warning: "You are using a non-standard NODE_ENV value in your environment"
  2. Build failure: "Error: <Html> should not be imported outside of pages/_document"

The same command works perfectly in:

  • Regular terminal on the same machine
  • Vercel deployment
  • GitHub Actions CI/CD

The extension is injecting VSCode's extension host environment variables into user commands, polluting the build environment.

What Should Happen?

Build commands should work identically whether run through Claude Code or in a terminal. The extension should not inject its own environment variables (particularly NODE_ENV) into user shell commands.

Error Messages/Logs

⚠ You are using a non-standard "NODE_ENV" value in your environment. This creates inconsistencies in the project and is strongly advised against. Read more: https://nextjs.org/docs/messages/non-standard-node-env Error: <Html> should not be imported outside of pages/_document. Read more: https://nextjs.org/docs/messages/no-document-import-in-page at x (.next/server/chunks/5611.js:6:1351) Error occurred prerendering page "/404". Read more: https://nextjs.org/docs/messages/prerender-error ⨯ Next.js build worker exited with code: 1 and signal: null

Steps to Reproduce

  1. Create a Next.js 15 project with App Router
  2. Open the project in VSCode with Claude Code extension
  3. Through Claude Code, run:

``bash
echo "NODE_ENV: '$NODE_ENV'" # Shows: NODE_ENV: 'development'
npm run build # Fails with error above
``

  1. In a regular terminal in the same directory:
echo "NODE_ENV: '$NODE_ENV'"  # Shows: NODE_ENV: ''
npm run build                  # Succeeds
  1. As a workaround, this works in Claude Code:
NODE_ENV= npm run build        # Succeeds

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

anthropic.claude-code-2.0.23-darwin-arm64 (VSCode Extension)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

VS Code integrated terminal

Additional Information

Environment Variables Injected by Claude Code:

CLAUDECODE=1
CLAUDE_CODE_ENTRYPOINT=claude-vscode
NODE_ENV=development

Root Cause Analysis:
The Claude Code VSCode extension runs within VSCode's Extension Host environment, which has NODE_ENV=development set. This environment variable is inherited and passed to all shell commands executed through Claude.

Architecture:

VSCode (Extension Host with NODE_ENV=development)
  └── Claude Code Extension
      └── Shell wrapper (/bin/zsh)
          └── User commands (inherits NODE_ENV)

Impact:

  • Affects any Node.js build tool that expects to control NODE_ENV
  • Causes mysterious build failures that are hard to debug
  • Creates inconsistency between Claude Code and terminal environments

Related Issues:

  • #401 discusses .env file loading, but this is a separate issue about VSCode's own environment variables polluting user commands

Suggested Fixes:

  1. Strip NODE_ENV before executing user commands
  2. Don't inherit VSCode's internal environment variables
  3. Make environment variable passthrough configurable in settings
  4. Document which environment variables are passed to commands

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗