{"id":795,"hash":"5732b75d5206b563dd3ca382bf8adbe20a51192a5637c7203c4500fbd9f259b2","pattern":"Vite production build errors: `...is not a constructor&#39; for node_modules","full_message":"I'm trying to do a build for a simple Vue-based project with Vite, but I am running into an error when actually processing the build.\n\nMy vite.config.js file:\n\nimport { defineConfig } from 'vite'\nimport vue from '@vitejs/plugin-vue'\nimport nodePolyfills from 'rollup-plugin-node-polyfills'\nimport commonjs from '@rollup/plugin-commonjs'\n\n// https://vitejs.dev/config/\nexport default defineConfig({\n  plugins: [\n    vue(),\n    nodePolyfills(),\n    commonjs(),\n  ],\n\n  resolve: {\n    alias: [\n      {\n        // this is required for the SCSS modules\n        find: /^~(.*)$/,\n        replacement: '$1',\n      },\n    ],\n  },\n\n  build: {\n    outDir: './dist',\n  },\n})\n\nThe build command vite build runs fine without warnings and compiles these files in the dist folder:\n\ndist/index.html\ndist/assets/index.83eff058.js\ndist/assets/index.acd5fd56.css\ndist/assets/vendor.96c4e7e1.js (the problem file)\n\nAnd when serving my built project, I get this error that crashes the entire thing and doesn't load anything besides CSS:\n\nUncaught TypeError: Vg is not a constructor\n    XA http://localhost:5000/assets/vendor.96c4e7e1.js:5\n    <anonymous> http://localhost:5000/assets/vendor.96c4e7e1.js:5\nvendor.96c4e7e1.js:5:11738\n    XA http://localhost:5000/assets/vendor.96c4e7e1.js:5\n    <anonymous> http://localhost:5000/assets/vendor.96c4e7e1.js:5\n    InnerModuleEvaluation self-hosted:2388\n    InnerModuleEvaluation self-hosted:2388\n    evaluation self-hosted:2349\n\nI've read through the Vite and Rollup documentation and really can't figure out what to even look for. Is this occurring because of the lack of Babel, or is this something else?","ecosystem":"npm","package_name":"vue.js","package_version":null,"solution":"If you are running Vite v3, you should look at this comment by sapphi-red:\n\nIt seems it's related to @rollup/plugin-commonjs v22.\n\nFor a workaround, use Esbuild Deps Optimization at Build Time.\nSet optimizeDeps.disabled = false and build.commonjsOptions.include = [].\n\nHere's a config that implements the workaround he mentioned:\n\nimport { defineConfig } from 'vite'\nimport react from '@vitejs/plugin-react'\n\n// https://vitejs.dev/config/\nexport default defineConfig({\n  plugins: [react()],\n  build: {\n    commonjsOptions: { include: [] },\n  },\n  optimizeDeps: {\n    disabled: false,\n  },\n});","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/70454977/vite-production-build-errors-is-not-a-constructor-for-node-modules","votes":17,"created_at":"2026-04-19T04:51:44.606676+00:00","updated_at":"2026-04-19T04:51:44.606676+00:00"}