Skip to content

Use case: WebDev BLOCKED -- shell invocations have NODE_ENV environment variable automatically set to production #151

Closed

Description

@mrairdon-midmark

Describe the bug

Open up copilot on Windows. Tell it to run dir Env:. What you'll see is the NODE_ENV environment variable set to production.

Automatically setting this means that jest tests behave differently when run in the copilot cli compared with regular invocations.

Affected version

0.0.330 Commit: a8bfefe

Activity

  1. dsmaher commented on Oct 11, 2025

    @dsmaher

    This is also the case running in WSL so I suspect this is not unique to Windows. This took a while for me to figure out why when copilot was working on a node.js project it had a very different experience from when I was working on it outside of copilot. The project would not install any devDependencies when copilot ran npm install (which makes sense, once I figured out the cause). I now add a **CRITICAL** hint to Copilot in my prompts to "ALWAYS unset NODE_ENV when running npm commands".

  2. Tiberriver256 commented on Oct 11, 2025

    @Tiberriver256

    @RyanHecht possible to raise the priority of this fix now that it's not just a Windows issue? Would really like to start using this tool for things that use node (webdev, etc.) and this makes it really difficult.

  3. mrairdon-midmark commented on Oct 15, 2025

    @mrairdon-midmark
    Author

    Just wanted to post here to say this is still an issue even with the latest updates.

    ┖[C:\..\..\..\v6]>$ENV:NODE_ENV; copilot -p "What's the value of `$ENV:NODE_ENV?" --allow-all-tools
    development
    ● I'll check the value of the NODE_ENV environment variable for you.
    
    ✓ Check NODE_ENV environment variable value
       $ $ENV:NODE_ENV
       ↪ 2 lines...
    ● The value of `$ENV:NODE_ENV` is **production**.
    
    
    Total usage est:       1 Premium request
    Total duration (API):  7.3s
    Total duration (wall): 17.9s
    Total code changes:    0 lines added, 0 lines removed
    Usage by model:
        claude-sonnet-4.5    106.6k input, 150 output, 54.9k cache read, 51.8k cache write (Est. 1 Premium request)
    

    Also, to give some clarity on the context of this problem. It is a blocker for being able to use this tool for web development. Most testing libraries in the web dev ecosystem key off of that environment variable.

  4. changed the title [-]PowerShell invocations have NODE_ENV environment variable automatically set to `production`[/-] [+]Use case: WebDev BLOCKED -- PowerShell invocations have NODE_ENV environment variable automatically set to `production`[/+] on Oct 15, 2025
  5. dsmaher commented on Oct 15, 2025

    @dsmaher

    @mrairdon-midmark I've been able to work around this problem by including the following in my prompts or in copilot-instructions.md:

     ***CRITICAL*** **ALWAYS** unset `NODE_ENV` when running `npm` commands.
    

    Phrasing it this way prioritizes this instruction to the LLM and it remembers it throughout the session when it runs tools, and can avoid the issues that arise from the current buggy behavior. Obviously you can update the phrasing so it sets NODE_ENV to whatever value you want and is used for any other commands you need it to handle.

    It's clearly not the right solution, but it at least unblocks my use cases. Hopefully this option can help you, too.

  6. mrairdon-midmark commented on Oct 15, 2025

    @mrairdon-midmark
    Author

    Thanks @dsmaher! That did help for me personally, but ultimately blocks me from recommending it widely within my org. Coordinating that bit across 40-50 devs will be a fun time, haha. I'd rather wait until it just works out of the box.

  7. uyrabi commented on Oct 20, 2025

    @uyrabi

    This also happens on Mac.

    When using a tool called vibe kanban, an error would sometimes occur only when AI was coding, but not when I did it manually.
    Upon investigation, I found that the NODE_ENV variable was being rewritten, which changed the behavior of the web framework (in my case, React Router v7).

    When I had the copilot cli output the value of NODE_ENV, it returned production.

  8. Tiberriver256 commented on Oct 23, 2025

    @Tiberriver256

    @andyfeller @RyanHecht

    Could we maybe get an update on this issue? Is out of the box support for web dev/node-based dev planned on the roadmap?

  9. changed the title [-]Use case: WebDev BLOCKED -- PowerShell invocations have NODE_ENV environment variable automatically set to `production`[/-] [+]Use case: WebDev BLOCKED -- shell invocations have NODE_ENV environment variable automatically set to `production`[/+] on Nov 7, 2025
  10. devm33 commented on Nov 9, 2025

    @devm33
    Member

    This is fixed in the latest prerelease 0.0.355-33

    npm i -g @github/copilot@prerelease
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions