你能覆盖 create-react-app@3.x 中的 NODE_ENV env 变量吗?
Can you override the NODE_ENV env variable in create-react-app@3.x?
我想在开发节点 (yarn run start
) 中构建我的 React 应用程序时手动更改 NODE_ENV
环境变量的值。
不,至少根据 create-react-app@3.4.1,这是不可能的。摘自docs:
There is also a built-in environment variable called NODE_ENV
. You can read it from process.env.NODE_ENV
. When you run npm start
, it is always equal to 'development', when you run npm test
it is always equal to 'test', and when you run npm run build
to make a production bundle, it is always equal to 'production'. You cannot override NODE_ENV manually. This prevents developers from accidentally deploying a slow development build to production.
我想在开发节点 (yarn run start
) 中构建我的 React 应用程序时手动更改 NODE_ENV
环境变量的值。
不,至少根据 create-react-app@3.4.1,这是不可能的。摘自docs:
There is also a built-in environment variable called
NODE_ENV
. You can read it fromprocess.env.NODE_ENV
. When you runnpm start
, it is always equal to 'development', when you runnpm test
it is always equal to 'test', and when you runnpm run build
to make a production bundle, it is always equal to 'production'. You cannot override NODE_ENV manually. This prevents developers from accidentally deploying a slow development build to production.