Since webpack v4, … 但是process.env中並不存在NODE_ENV這個東西。. Alternatively, the EnvironmentPlugin supports an object, … React + webpack: 'process.env' is undefined : codehunter The webpack command line environment option--env allows you to pass in as many environment variables as you like. Webpack process.env.VARIABLE_NAME returns undefined because the Node.js execution environment does not know the newly added VARIABLE_NAME yet. The problem is that you're storing the single quotes in NODE_ENV , so … Third, in conjunction with a tool like UglifyJS that does minification and removal of dead code blocks, … while I got it in my webpack config and it works perfectly but in Typescript not. webpack In this file, we have access to the process.env property. but the log result is 'undefined' Why ? process.env Individually designed curtains and blinds. EnvironmentPlugin (['NODE_ENV', 'DEBUG']);. 或者说非 Node 框架中的 process.env.NODE_ENV 天生就是为了打包器而设计。. plugins: [ new webpack. There are a few use cases in real applications where this feature becomes especially neat.