Skip to content

Commit 3a090bd

Browse files
authored
chore: remove express example
It feels weird to provide an example of one specific framework so in-depth. Signed-off-by: Claudio W <cwunder@gnome.org>
1 parent 2226f7a commit 3a090bd

File tree

1 file changed

+0
-37
lines changed

1 file changed

+0
-37
lines changed

apps/site/pages/en/learn/getting-started/nodejs-the-difference-between-development-and-production.md

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,43 +12,6 @@ Always run your Node.js with the `NODE_ENV=production` set.
1212

1313
A popular way of configuring your application is by using the [twelve factor methodology](https://12factor.net/).
1414

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:
37-
38-
```js
39-
if (process.env.NODE_ENV === 'development') {
40-
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
41-
}
42-
43-
if (process.env.NODE_ENV === 'production') {
44-
app.use(express.errorHandler());
45-
}
46-
```
47-
48-
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-
5215
## Why is NODE_ENV considered an antipattern?
5316

5417
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

Comments
 (0)