Environment variables can be set through NODE_ENV (the default value is development). Run the following command in the terminal to get the debugging data of the development environment, such as logs, mongodb data operations, etc. Generally, we perform different processing on the development environment and production environment by checking this value. This value can be set on the command line in the following way:
linux & mac: export NODE_ENV=production windows:set NODE_ENV=production For example, if the code needs to do some processing in the production environment, you can write like this:
if (process.env.NODE_ENV === 'production') { // just for production code }
NODE_ENV is the environment variable of node.js and is part of the node.js module search. If it is not set, node.js will report a not found error after installing the global module
For example, your code has a development (development) environment, a test (test) environment and an online (production-) environment. When you write code, you may develop it locally in the development environment first, then move to the test environment, and finally go online. How to control switching between different environments? This env is used at this time. According to the terminal's export NODE_ENV=test/NODE_ENV=development/NODE_ENV=production, you can get different environment variable parameters. Make different configurations based on these parameters, and then package them to get what you want. Production Environment.
Environment variables can be set through NODE_ENV (the default value is development). Run the following command in the terminal to get the debugging data of the development environment, such as logs, mongodb data operations, etc. Generally, we perform different processing on the development environment and production environment by checking this value. This value can be set on the command line in the following way:
linux & mac: export NODE_ENV=production
windows:set NODE_ENV=production
For example, if the code needs to do some processing in the production environment, you can write like this:
if (process.env.NODE_ENV === 'production') {
// just for production code
}
php also has getenv putenv
NODE_ENV is the environment variable of node.js and is part of the node.js module search. If it is not set, node.js will report a not found error after installing the global module
For example, your code has a development (development) environment, a test (test) environment and an online (production-) environment. When you write code, you may develop it locally in the development environment first, then move to the test environment, and finally go online. How to control switching between different environments? This env is used at this time. According to the terminal's export NODE_ENV=test/NODE_ENV=development/NODE_ENV=production, you can get different environment variable parameters. Make different configurations based on these parameters, and then package them to get what you want. Production Environment.