Skip to content

Using in Vite/Vue3 App Throws 'Uncaught TypeError: util.inherits is not a function' #15

@mwoodward-atd

Description

@mwoodward-atd

When attempting to instantiate a Client object in a Vite/Vue3 app, the error Uncaught TypeError: util.inherits is not a function is thrown.

Environment

  • Node 18.16

Steps to Reproduce

  1. Create a new Vite/Vue3 app, install dependencies, and launch app
npm create vite@latest duo-vite-test -- --template vue
cd duo-vite-test
npm install
npm install @duosecurity/duo_universal
npm run dev
  1. Instantiate Client in App.vue <script setup> block
import { Client } from '@duosecurity/duo_universal'

const client = new Client({
  clientId: 'theclientid',
  clientSecret: 'theclientsecret',
  apiHost: 'theapihost',
  redirectUrl: 'http://localhost:5173',
})
  1. When the app reloads, the following error is thrown:
Uncaught TypeError: util.inherits is not a function
    at node_modules/jws/lib/data-stream.js (data-stream.js:39:6)
    at __require (chunk-OL3AADLO.js?v=606a3168:9:50)
    at node_modules/jws/lib/sign-stream.js (sign-stream.js:3:18)
    at __require (chunk-OL3AADLO.js?v=606a3168:9:50)
    at node_modules/jws/index.js (index.js:2:18)
    at __require (chunk-OL3AADLO.js?v=606a3168:9:50)
    at node_modules/jsonwebtoken/decode.js (decode.js:1:11)
    at __require (chunk-OL3AADLO.js?v=606a3168:9:50)
    at node_modules/jsonwebtoken/verify.js (verify.js:4:16)
    at __require (chunk-OL3AADLO.js?v=606a3168:9:50)
triggerError @ vue-router.mjs:3451
(anonymous) @ vue-router.mjs:3173
Promise.catch (async)
pushWithRedirect @ vue-router.mjs:3167
push @ vue-router.mjs:3099
install @ vue-router.mjs:3530
use @ runtime-core.esm-bundler.js:4381
start @ client-entry.js?t=1686682252177:120
await in start (async)
(anonymous) @ client-entry.js?t=1686682252177:165
Promise.then (async)
(anonymous) @ client-entry.js?t=1686682252177:163
Promise.then (async)
(anonymous) @ client-entry.js?t=1686682252177:139

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions