Browser polyfill for `process.env`
See original GitHub issueEnvironment
Nuxt CLI v3.0.0-27375427.d07d572
RootDir: /home/kael/Documents/vuetifyjs/test-projects/nuxt3/nuxt3-app
Nuxt project info:
------------------------------
- Operating System: `Linux`
- Node Version: `v16.13.2`
- Nuxt Version: `3.0.0-27375427.d07d572`
- Package Manager: `yarn@1.22.5`
- Bundler: `Vite`
- User Config: `css`, `build`, `vite`
- Runtime Modules: `-`
- Build Modules: `-`
------------------------------
Reproduction
Create a plugin with
console.log(typeof process)
console.log(process.env.NODE_ENV)
and look at the browser console.
Describe the bug
process
is { dev: true, server: false, client: true }
, should be undefined
process.env.NODE_ENV
throws TypeError: Cannot read properties of undefined (reading 'NODE_ENV')
, should be 'development'
Additional context
This works with just vite, idk what you’re doing to disable that. It looks like this is also set up correctly for builds with @rollup/plugin-replace
, so it’s only a problem during dev.
Logs
No response
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:12 (5 by maintainers)
Top Results From Across the Web
Node process object made available to browser client code
These options configure whether to polyfill or mock certain Node.js globals and modules. This allows code originally written for the Node.js ...
Read more >Undeclared use of node's process causes exception ... - GitHub
Webpack 5 no longer ships polyfills for nodejs builtin modules, and recommends using this module if a module need util, and the module ......
Read more >Node Emulation - Parcel
Polyfilling & Excluding Builtin Node Modules ... When targetting the browser and your code, or more likely a dependency, imports builtin Node modules...
Read more >node-polyfill-webpack-plugin - npm
Polyfill Node.js core modules in Webpack.. Latest version: 2.0.1, last published: 5 months ago. Start using node-polyfill-webpack-plugin in ...
Read more >Polyfill Node.js built-in modules with Vite | by Fabiano Taioli
Polyfill Node.js built-in modules with Vite · A dev server that serves your source files over native ES modules, with rich built-in features...
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
Hello everyone This happen to me as well using nuxt rc11 when trying to use theatre.js, I found a workaround using
vite.define
object innuxt.config.ts
. After that,process
look like this :{ dev: true, server: false, client: true, env: {} }
and dependencies work as intended and doesn’t seem to be broken.Here is the
nuxt.config.ts
file I used, I hope that could be helpfulThis seems appear again. The
process
in browser doesn’t have aenv
property that breaks some packages.