You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
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
[x ] Read
the docs
.
[x ] Use Vite >=2.0. (1.x is no longer supported)
[ x] If the issue is related to 1.x -> 2.0 upgrade, read the
Migration Guide
first.
Describe the bug
When I upgrade vite to any version after 2.0.0-beta.62 I get the error as follows:
App.vue:36 Uncaught ReferenceError: process is not defined
at setup (App.vue:36)
at callWithErrorHandling (runtime-core.esm-bundler.js:154)
at setupStatefulComponent (runtime-core.esm-bundler.js:6419)
at setupComponent (runtime-core.esm-bundler.js:6380)
at mountComponent (runtime-core.esm-bundler.js:4118)
at processComponent (runtime-core.esm-bundler.js:4094)
at patch (runtime-core.esm-bundler.js:3712)
at render2 (runtime-core.esm-bundler.js:4794)
at mount (runtime-core.esm-bundler.js:3019)
at Object.app.mount (runtime-dom.esm-bundler.js:1220)
Reproduction
https://github.com/ljcremer/vite-test
System Info
vite
version: 2.0.0-beta.67
Operating System: Windows 10
Node version:v12.19.1
Package manager (npm/yarn/pnpm) and version:6.14.8
Logs (Optional if provided reproduction)
Run
vite
or
vite build
with the
--debug
flag.
Provide the error log here.
freeser, yuruyuri16, talentlessguy, artnikbrothers, bitcoinvsalts, gormlabenz, and wilf312 reacted with thumbs up emoji
gustawdaniel and minosss reacted with thumbs down emoji
All reactions
Why is process.env removed? A lot of existing libraries use this. Including blueprintjs (Example:
https://github.com/palantir/blueprint/blob/develop/packages/core/src/common/classes.ts
)
The consequence is that I can't use the blueprintjs (without forking and modifying the library). Would it at least be possible to provide process.env as an alias to import.meta.env?
I found that I can use the following in vite.config.ts to avoid "Uncaught ReferenceError: process is not defined":
import { defineConfig } from 'vite'
// ...
export default defineConfig({
// ...
define: {
'process.env': {}
Holajuwon, xiaoxin-sky, Hammster, jacksteamdev, snowdream, zxbodya, mcmillenb, timmaier, natalie-o-perret, bitcoinvsalts, and 15 more reacted with thumbs up emoji
mecirmartin, Lord-Y, and marcmec reacted with rocket emoji
All reactions
Is there any way to support process.env way to access dotenv?
The problem is that using import.meta goes in conflict with jest (we use typescript):
kulshekhar/ts-jest#1174
And there's no viable way of using it for us without introducing babel and additional overhead.
The only other strategy is to give up on using Vite and roll back to vue cli, which is something that we are trying to avoid since we like Vite performances.
Is there any other way to set process.env?
I found that I can use the following in vite.config.ts to avoid "Uncaught ReferenceError: process is not defined":
import { defineConfig } from 'vite'
// ...
export default defineConfig({
// ...
define: {
'process.env': {}
I personally do:
export default defineConfig({
// ...
define: {
'process.env': process.env
I found that I can use the following in vite.config.ts to avoid "Uncaught ReferenceError: process is not defined":
import { defineConfig } from 'vite'
// ...
export default defineConfig({
// ...
define: {
'process.env': {}
I personally do:
export default defineConfig({
// ...
define: {
'process.env': process.env
This works for me while development but after build process becomes undefined.
All of these issues relating to undefined globals appear closed with no real resolutions. Is there some way of polyfilling these things (process, global, etc.) that actually works? I've tried rollup plugins like rollup-plugin-polyfill-node but im still facing issues.
Obviously the real culprit here is libraries which are behind the curve in supporting esm properly, but sometimes we need to use them.
Is there any way to support process.env way to access dotenv?
The problem is that using import.meta goes in conflict with jest (we use typescript):
kulshekhar/ts-jest#1174
And there's no viable way of using it for us without introducing babel and additional overhead.
The only other strategy is to give up on using Vite and roll back to vue cli, which is something that we are trying to avoid since we like Vite performances.
Is there any other way to set process.env?
Have you found any solution to this? Having the exact same issue at the moment.