Skip to content

Request - set NODE_ENV="production" on prod build/serve #2110

Closed

Description

@vicrep

Please provide us with the following information:

  1. OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
    OSX 10.11.6
  2. Versions. Please run ng --version. If there's nothing outputted, please run
    in a Terminal: node --version and paste the result here:
    angular-cli: 1.0.0-beta.11-webpack.9-2
    node: 6.5.0
    os: darwin x64
  3. Repro steps. Was this an app that wasn't created using the CLI? What change did you
    do on your code? etc.
    Include a npm package which uses React and run a prod-build/serve.
  4. The log given by the failure. Normally this include a stack trace and some
    more information.
    Warning: It looks like you're using a minified copy of the development build of React. When deploying React apps to production, make sure to use the production build which skips development warnings and is faster. See https://fb.me/react-minification for more details.
  5. Mention any other details that might be useful.
    This can be solved by setting the NODE_ENV to "production" on prod build (i.e. set process.env.NODE_ENV = 'production'; in build script). I'd be happy to submit a PR for this if interested.

Thanks! We'll be in touch soon.

Activity

  1. filipesilva commented on Sep 21, 2016

    @filipesilva
    Contributor

    @TheLarkInn can you weigh in?

  2. TheLarkInn commented on Sep 21, 2016

    @TheLarkInn
    Member

    @gaearon is there any other way to flip this flag? Just want to know our available options.

  3. gaearon commented on Sep 21, 2016

    @gaearon

    We just want process.env.NODE_ENV to be envified to become "production" in the bundled code. We don’t actually care about process.env.NODE_ENV of the build scripts, just that you DefinePlugin({ "process.env.NODE_ENV": "\"production\"" }) when you build.

  4. TheLarkInn commented on Sep 21, 2016

    @TheLarkInn
    Member

    Thank you very much, @gaearon. @filipesilva this would require a change, maybe falls into future add-on system. Though implementing this would likely not collide or conflict as the use case is probably edge.

  5. Australhawk commented on Oct 3, 2016

    @Australhawk

    ng build --prod Should set NODE_ENV to production by default, im having this exact issue with Redux. Any workarounds?

  6. rthewhite commented on Oct 11, 2016

    @rthewhite

    @TheLarkInn should this indeed use the future add-on system or is it ok to put this in the default production webpack configuration? Running into this issue as well, more then willing to put in a pull request.

    Been trying to find a workaround for it without having to fork and run my own version of the angular-cli but running out of ideas.

  7. filipesilva commented on Oct 14, 2016

    @filipesilva
    Contributor

    Now that I think about it, can you not just set it manually via export NODE_ENV=production? You could even put it in a npm script export NODE_ENV=production && ng build -prod.

    This seems to be a React specific thing and I'd rather not introduce changes to the build pipeline because of it.

  8. danimbrogno commented on Oct 14, 2016

    @danimbrogno

    @filipesilva Just tried your suggestion but it didn't seem to work for me.

    "scripts": {
        "build": "export NODE_ENV=production && ng build --prod",
        "prepublish": "npm run build"
      }
    

    Still results in

    You are currently using minified code outside of NODE_ENV === 'production'.

  9. rthewhite commented on Oct 14, 2016

    @rthewhite

    That's because that check is being done runtime by Redux. What we need is the webpack define plugin to set NODE_ENV global variable within the bundle. It's not something React specific and it's probably gonna be needed for more packages.

  10. filipesilva commented on Oct 15, 2016

    @filipesilva
    Contributor

    @rthewhite I'll reopen then, but haven't had any report outside of React/Redux so far so I have to say this isn't very high on the priority list.

  11. added
    P5The team acknowledges the request but does not plan to address it, it remains open for discussion
    and removed
    needs: investigationRequires some digging to determine if action is needed
    on Oct 15, 2016
  12. rthewhite commented on Oct 15, 2016

    @rthewhite

    @filipesilva I can understand that it's not very high on the priority list. I'm more then willing to create a PR for it so you guys can see if it doesn't have any undesirable side effects and what the impact would be?

  13. filipesilva commented on Oct 15, 2016

    @filipesilva
    Contributor

    That would be welcome, yes. I could bring up the implementation among the team and see what we decide.

  14. added 5 commits that reference this issue on Oct 18, 2016
    e8408b0
    77416bd
    27b5b9f
    fbbc43f
    e23e0fe
  15. rthewhite commented on Oct 18, 2016

    @rthewhite

    Thank you for solving this, didn't get to making the PR yet. Great that it's implemented now 👍

  16. added a commit that references this issue on Oct 21, 2016
    9672aef
  17. angular-automatic-lock-bot commented on Sep 6, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  18. locked and limited conversation to collaborators on Sep 6, 2019
  19. added a commit that references this issue on May 29, 2026
    2c2b853
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

    P5The team acknowledges the request but does not plan to address it, it remains open for discussion

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions