Skip to content

NODE_ENV always in development #12193

@alXDraghiciu

Description

@alXDraghiciu

Describe the bug

Hi. My created app is always stuck in development mode when deployed to Heroku in production and I cannot use .env.production.

Did you try recovering your dependencies?

The dependencies are built on Heroku.

Which terms did you search for in User Guide?

I've found some older posts on Google but none of the answers helped me.

Environment

current version of create-react-app: 5.0.0

System:
OS: Windows 10 10.0.19042
CPU: (8) x64 Intel(R) Core(TM) i5-10210U CPU @ 1.60GHz
Binaries:
Node: 16.14.1 - C:\Program Files\nodejs\node.EXE
Yarn: Not Found
npm: 8.5.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: Not Found
Edge: Spartan (44.19041.1266.0), Chromium (99.0.1150.46)
Internet Explorer: 11.0.19041.1566
npmPackages:
react: ^17.0.2 => 17.0.2
react-dom: ^17.0.2 => 17.0.2
react-scripts: 5.0.0 => 5.0.0
npmGlobalPackages:
create-react-app: Not Found

Steps to reproduce

I created an app and made a few components. I also use axios to make API calls and I need different values for development and production.

I've also tried creating a brand-new app using the script. Same result.

  1. Create a new app via script
    npx create-react-app my-app
  2. Add You are running this application in <b>{process.env.NODE_ENV}</b> mode. somewhere in App.js
  3. Create a new Heroku app
  4. Deploy using Heroku Git
  5. Visit the deployed app in the browser.

Expected behavior

NODE_ENV should be in production mode. It's always in development mode despite the npm run build command being used.

Actual behavior

(Write what happened. Please add screenshots!)

Reproducible demo

(Paste the link to an example project and exact instructions to reproduce the issue.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions