Error: env [NODE_ENV] is not set (How to Solve)

Error: env [NODE_ENV] is not set

Encountered problem: running project reports error: env [node_env] is not set

Screenshot of the problem:

Solution idea, env in NODE_ENV is not set, resulting in process failure, so you can set the value of this NODE_ENV can be solved. Because it is someone else’s project, I took it over directly, so I searched NODE_ENV globally and found that NODE_ENV=development, so just set NODE_ENV to development.

Implementation method:

1. For Linux:

NODE_ENV=development node foo.js

2. For Windows

SET NODE_ENV=development
node foo.js

Write node foo according to the actual needs of the project JS, some projects can not be written

tips:

It is possible that in addition to the property NODE_ENV is not set, there are other values that are not set, for the same reason, you can set the corresponding value for this value

Read More: