Uncaught ReferenceError: process is not defined
See original GitHub issue- [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
orvite build
with the--debug
flag. - Provide the error log here.
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (3 by maintainers)
Top Results From Across the Web
javascript - Uncaught ReferenceError: process is not defined
Node.js code must be run by the node process, not the browser (the code must run in the server). To run the code,...
Read more >ReferenceError: “process is not defined” - GIMTEC
In this case, process is not defined in the browser environment, hence the error. The solution is to remove the reference to process...
Read more >React ReferenceError: process is not defined | bobbyhadz
To solve the "Uncaught ReferenceError: process is not defined" in React, open your terminal in your project's root directory and update the version...
Read more >"Uncaught ReferenceError: process is not defined" and the ...
The Uncaught ReferenceError: process is not defined happens when when a non-existent (here: process) variable is referenced .
Read more >process is not defined (NOT react-error-overlay ... - GitHub
Using the optional chaining operator with process ( process?.env ) throws a ReferenceError stating that process is not defined. I originally ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I found that I can use the following in vite.config.ts to avoid “Uncaught ReferenceError: process is not defined”:
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): https://github.com/kulshekhar/ts-jest/issues/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?