Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Showing util.inherits is not a function while importing jwt in vue vite.js

Tags:

vue.js

vite

enter image description here

Showing util.inherits is not a function while importing jwt in vue vite

like image 468
user1744669 Avatar asked Jan 24 '26 16:01

user1744669


1 Answers

since util is a node built in it won't get polyfill by vite, add this plugin to your project

npm install --save-dev vite-plugin-node-polyfills

and then you add this to your vite.config.js

import { defineConfig } from 'vite'
import { nodePolyfills } from 'vite-plugin-node-polyfills'

export default defineConfig({
  plugins: [
    nodePolyfills(),
  ],
})
like image 64
Rodrigo Klim Avatar answered Jan 26 '26 16:01

Rodrigo Klim