Closed
Description
Describe the bug
Running vite dev
substitutes globalThis.process.env.NODE_ENV
into globalThis."development"
. This causes console error SyntaxError: Unexpected string
. This kind of code is usually in some dependency and can not be easily replaced.
It looks like this is a known problem but I have not found any issue reported here nor in documentation how it can be solved. Here is one potential "workaround" https://github.com/DougAnderson444/ipfs-vite-svelte-kit#processenvnode_env-in-svelte-dev
Reproduction
https://stackblitz.com/edit/vitejs-vite-kfsmj6?file=counter.js
Steps to reproduce
Just use globalThis.process.env.NODE_ENV
somewhere in code and run vite dev
System Info
System:
OS: macOS 13.2.1
CPU: (8) arm64 Apple M1
Memory: 184.16 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.14.2 - ~/.nvm/versions/node/v16.14.2/bin/node
Yarn: 1.22.15 - ~/.nvm/versions/node/v16.14.2/bin/yarn
npm: 8.19.4 - ~/.../node_modules/.bin/npm
Browsers:
Brave Browser: 110.1.48.164
Chrome: 110.0.5481.177
Safari: 16.3
Used Package Manager
npm
Logs
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 vuejs/core 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.
Activity