You can have different configurations for production and development environments.
Node assumes it’s always running in a development environment.

You can signal Node.js that you are running in production by setting the NODE_ENV=production environment variable.This is usually done by executing the command.

export NODE_ENV=production

in the shell, but it’s better to put it in your shell configuration file (e.g. .bash_profile with the Bash shell) because otherwise the setting does not persist in case of a system restart.

You can also apply the environment variable by prepending it to your application initialization command:

NODE_ENV=production node app.js

This environment variable is a convention that is widely used in external libraries as well.Setting the environment to production generally ensures that

  • logging is kept to a minimum, essential level.
  • more caching levels take place to optimize performance.

For example Pug, the templating library employed by Express, compiles in debug mode if
NODE_ENV is not set to production .

Express views are compiled in every request in development mode, while in production they are cached. There are many more examples.Express provides configuration hooks specific to the environment, which are automatically called based on the NODE_ENV variable value:

app.configure('development', () => {
app.configure('production', () => {
app.configure('production', 'staging', () => {

For example you can use this to set different error handlers for different mode:

app.configure('development', () => {

app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));


app.configure('production', () => {



Express development environment

The categorical development atmosphere includes associate degree installation of Nodejs, the NPM package manager, and (optionally) the categorical Application Generator on your native pc.

Node and also the NPM package manager square measure put in along from ready binary packages, installers, software package managers or from supply .(as shown within the following sections).categorical is then put in by NPM as a dependency of your individual categorical internet applications.

(along with different libraries like model engines, information drivers, authentication middleware, middleware to serve static files, etc.)

NPM also can be accustomed (globally) install the categorical Application Generator, a handy tool for making skeleton categorical internet apps that follow the MVC pattern.

 the appliance generator is nonmandatoryas a result of you do not have to be compelled to use this tool to form apps that use categorical, or construct categorical apps that have a similar beaux arts layout or dependencies.

We’ll be victimisation it although, as a result of it makes obtaining started loads easier, and promotes a standard application structure.

If you like this post, don’t forget to share 🙂

This article is written by our awesome writer
Comments to: Difference between development and production In Node.Js

Your email address will not be published. Required fields are marked *

Attach images - Only PNG, JPG, JPEG and GIF are supported.

New Dark Mode Is Here

Sign In to access the new Dark Mode reading option.

Join our Newsletter

Get our monthly recap with the latest news, articles and resources.

By subscribing you agree to our Privacy Policy.

Latest Articles

Explore Tutorials By Categories


Codeverb is simply an all in one interactive learning portal, we regularly add new topics and keep improving the existing ones, if you have any suggestions, questions, bugs issue or any other queries you can simply reach us via the contact page


Welcome to Codeverb

Ready to learn something new?
Join Codeverb!

Read Smart, Save Time
    Strength indicator
    Log In | Lost Password