-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
Uncaught ReferenceError: process is not defined #1973
Comments
|
As @CHOYSEN said. |
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': {}
}
}) |
Is there any way to support process.env way to access dotenv? 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 personally do: export default defineConfig({
// ...
define: {
'process.env': process.env
}
}) |
This works for me while development but after build |
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 Obviously the real culprit here is libraries which are behind the curve in supporting esm properly, but sometimes we need to use them. |
Indeed. E.g.: How can I display the current app version from package.json to the user using Vite? |
@Obiwarn try to take a look at this package https://github.com/smnhgn/vite-plugin-package-version |
@Niputi Thank you. I tried this already but got some errors. ("0.0.1" is not a number) |
Have you found any solution to this? Having the exact same issue at the moment. |
This issue has been locked since it has been closed for more than 14 days. If you have found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest Vite version. If you have any other comments you should join the chat at Vite Land or create a new discussion. |
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.67Logs (Optional if provided reproduction)
vite
orvite build
with the--debug
flag.The text was updated successfully, but these errors were encountered: