Closed melsayedgit closed 11 months ago
Hey there. 👋 Can you share your Vite config or provide a reproduction for me?
Hello, I've encountered the same/similar error.
My config was the default one, but I've tried to play with the globals properties (disabling process and global) since I only needed to polyfill 'path'.
It did not worked either way.
import { defineConfig } from 'vite'
import { nodePolyfills } from 'vite-plugin-node-polyfills'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
nodePolyfills({
// To exclude specific polyfills, add them to this list.
exclude: [
'fs', // Excludes the polyfill for `fs` and `node:fs`.
],
// Whether to polyfill specific globals.
globals: {
Buffer: true, // can also be 'build', 'dev', or false
global: true,
process: true,
},
// Whether to polyfill `node:` protocol imports.
protocolImports: true,
}),
],
})
My error was slighly different, it was 'Uncaught TypeError: Cannot read properties of undefined (reading 'isTTY')', from this code (from jest-util):
var _default =
!!process.stdout.isTTY && process.env.TERM !== 'dumb' && !_ciInfo().isCI;
exports.default = _default;
My context is specific, I am running Mocha tests using WebDriverIO browser runner (which use Vite).
I do not have this error when I am not using the plugin.
I ended up using path-browserify
manually, as an alias.
Hey @isirode. I still need a reproduction in order to debug this. If you can provide a StackBlitz or CodeSandbox example of this error, I should be able to diagnose the issue and get a fix out.
Hi, sorry, I had forgotten about it since I did not used it in the end, I will try to provide a reproduction when I have time.
I'm closing this since I cannot reproduce it. Please open a new issue if this is still a problem.
ReferenceError: process is not defined