Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Uncaught TypeError: Object prototype may only be an Object or null: undefined vite jws

// The cheapest way I found to “solve” this issue in vite is to mock node.js modules in vite.config.ts:

define: {
    global: {},
    stream: {},
    process: {},
 },

// and to fake “inherits” module and do the check there
{
resolve: {
    alias: {
      inherits: './inherits.js',
    },
  },
}

//in inherits.js you can put an easy check.
function inherits(ctor, superCtor) {
  if (!superCtor.prototype) return;
  // eslint-disable-next-line no-underscore-dangle
  ctor.super_ = superCtor;
  ctor.prototype = Object.create(superCtor.prototype, {
    constructor: {
      value: ctor,
      enumerable: false,
      writable: true,
      configurable: true,
    },
  });
}
module.exports = inherits;
Source by lightrun.com #
 
PREVIOUS NEXT
Tagged: #Uncaught #Object #prototype #Object #undefined #vite #jws
ADD COMMENT
Topic
Name
1+4 =