Skip to content

Should npm start default NODE_ENV to 'production' #607

@kingcody

Description

@kingcody

I wanted to gauge the community's thoughts on this (possible PR).

The question is (like the title): should the npm start command set the NODE_ENV environment variable to 'production' by default if it hasn't been set already? This would allow people to deploy a built /dist folder by simply issuing npm start in that directory.

Many PAAS and other deployment systems already expect npm start to be the main entry point for a node app, I understand that many of those same services also allow you to set ENVs through some fashion. However, if they did not; this could simplify the process for them. Another point to make might be that the user has not generated an app that would required any other ENVs to be set (ei no auth) other than NODE_ENV, this would eliminate that need for them completely.

I don't think that this change would likely affect anyone in a negative way, as I doubt many (if any) run the app in development with npm start instead of grunt serve; but I'd like to hear the feedback on this assumption.

Here is the proposed npm start script:

...
  "scripts": {
    "start": "[[ ! $NODE_ENV ]] && NODE_ENV='production' && export NODE_ENV; node server/app.js",
...

As mentioned, the behavior could be overridden with NODE_ENV='whatever' npm start

Let me know what you think.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions