Vite4 production environment packaging error NODE_ENV=production is not supported in the .env file.

Vue3+vite4 production environment production packaging error:

NODE_ENV=production is not supported in the .env file. Only NODE_ENV=development is supported to create a development build of your project. If you need to set process.env.NODE_ENV, you can set it in the Vite config instead.

insert image description here
The general meaning is:
NODE_ENV=The production is not supported in the .ENV file. Only NODE_ENV=development is supported to create a development build of the project. If you need to set process.env.NODE_env, you can set it in Vite configuration.
**

Solution: downgrade version 3+ of vite

**
if warning

build.terserOptions is specified but build.minify is not set to use Terser. Note Vite now defaults to use esbuild for minification. If you still prefer Terser, set build.minify to "terser".

Then replace minify in vite.config.js with: terser (don’t forget to install and download)
insert image description here

Guess you like

Origin blog.csdn.net/weixin_45324044/article/details/128497307