We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
process.env.NODE_ENV
I want to prevent vitest from setting process.env.NODE_ENV.
vitest
Because vite supports setting process.env.NODE_ENV in env files, e.g. .env files. But vite only allows setting when process.env.NODE_ENV is undefined.
vite
undefined
I want to prevent vitest set NODE_ENV.
Because vite support process.env.NODE_ENV set in env file, e.g: .env file. but vite only allow to set when process.env.NODE_ENV is undefined
vitest/packages/vitest/src/node/cli-api.ts
Line 18 in 4701e0b
vitejs/vite#8218
Add preventSetNodeEnv option, default is false. Don't set process.env.NODE_ENV when preventSetNodeEnv is true.
preventSetNodeEnv
false
No response
vitejs/vite#8218 (comment)
The text was updated successfully, but these errors were encountered:
Your examples shows that NODE_ENV is not set, if it was already set. So, what is the problem here?
Sorry, something went wrong.
If it is already set, causing NODE_ENV in the env file to not work.
NODE_ENV
https://github.com/vitejs/vite/pull/8218/files#diff-11e17761d4ecfee8f8fde15c6d79b7bc0260176396a30dfd8e6f6bbaf5af4745R399
I found the workaround. We can override process.env.NODE_ENV with the env option.
Lines 35 to 36 in 4701e0b
No branches or pull requests
Clear and concise description of the problem
I want to prevent
vitest
from settingprocess.env.NODE_ENV
.Because
vite
supports settingprocess.env.NODE_ENV
in env files, e.g. .env files. But vite only allows setting whenprocess.env.NODE_ENV
isundefined
.I want to prevent
vitest
set NODE_ENV.Because
vite
supportprocess.env.NODE_ENV
set in env file, e.g: .env file. but vite only allow to set whenprocess.env.NODE_ENV
isundefined
Related code
vitest/packages/vitest/src/node/cli-api.ts
Line 18 in 4701e0b
Related pr:
vitejs/vite#8218
Suggested solution
Add
preventSetNodeEnv
option, default isfalse
.Don't set
process.env.NODE_ENV
whenpreventSetNodeEnv
is true.Alternative
No response
Additional context
vitejs/vite#8218 (comment)
Validations
The text was updated successfully, but these errors were encountered: