Skip to content
New issue

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

Unexpected string when using globalThis.process.env.NODE_ENV #12185

Closed
7 tasks done
vojtechsimetka opened this issue Feb 24, 2023 · 2 comments · Fixed by #12194
Closed
7 tasks done

Unexpected string when using globalThis.process.env.NODE_ENV #12185

vojtechsimetka opened this issue Feb 24, 2023 · 2 comments · Fixed by #12194
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@vojtechsimetka
Copy link

vojtechsimetka commented Feb 24, 2023

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

Screenshot 2023-02-24 at 12 02 42

Validations

@faga295
Copy link

faga295 commented Feb 24, 2023

maybe you can use process.env.NODE_ENV instead

@vojtechsimetka
Copy link
Author

Thanks but this is used in dependency i am bundling so I can't really change it.

@sapphi-red sapphi-red added the p3-minor-bug An edge case that only affects very specific usage (priority) label Feb 24, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Mar 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants