bug(ssr): process.env.xxx is undefined when calling ssrloadmodules api #5435
Closed
Description
Describe the bug
From this pr which cause process.env.FOO
is undefined in nodejs environment and we must use process.env['FOO']
to get the right value because process.env
will be replaced with ({})
Reproduction
$ git clone git@github.com:zhangyuang/vite-ssr-error-require.git
$ git checkout bug/env
System Info
$ npx envinfo --system --npmPackages '{vite,@vitejs/*}' --binaries --browsers
System:
OS: macOS 10.15.4
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 278.79 MB / 16.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 14.17.2 - ~/.nvm/versions/node/v14.17.2/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 7.17.0 - /usr/local/bin/npm
Browsers:
Chrome: 95.0.4638.54
Safari: 13.1
npmPackages:
@vitejs/plugin-vue: ^1.0.0 => 1.9.3
@vitejs/plugin-vue-jsx: ^1.0.0 => 1.2.0
vite: ^2.6.11 => 2.6.11
Used Package Manager
yarn
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.