You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/site/pages/en/learn/getting-started/nodejs-the-difference-between-development-and-production.md
-37Lines changed: 0 additions & 37 deletions
Original file line number
Diff line number
Diff line change
@@ -12,43 +12,6 @@ Always run your Node.js with the `NODE_ENV=production` set.
12
12
13
13
A popular way of configuring your application is by using the [twelve factor methodology](https://12factor.net/).
14
14
15
-
## NODE_ENV in Express
16
-
17
-
In the wildly popular [express](https://expressjs.com/) framework, setting the `NODE_ENV` to `production` generally ensures that:
18
-
19
-
- logging is kept to a minimum, essential level
20
-
- more caching levels take place to optimize performance
21
-
22
-
This is usually done by executing the command
23
-
24
-
```bash
25
-
export NODE_ENV=production
26
-
```
27
-
28
-
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.
29
-
30
-
You can also apply the environment variable by prepending it to your application initialization command:
31
-
32
-
```bash
33
-
NODE_ENV=production node app.js
34
-
```
35
-
36
-
For example, in an Express app, you can use this to set different error handlers per environment:
For example [Pug](https://pugjs.org), the templating library used by [Express](https://expressjs.com), 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.
49
-
50
-
**This environment variable is a convention widely used in external libraries, but not within Node.js itself**.
51
-
52
15
## Why is NODE_ENV considered an antipattern?
53
16
54
17
An environment is a digital platform or a system where engineers can build, test, _deploy_, and manage software products. Conventionally, there are four stages or types of environments where our application is run:
0 commit comments