Skip to content

bug(ssr): process.env.xxx is undefined when calling ssrloadmodules api #5435

Closed
@zhangyuang

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions