Uncaught TypeError: Cannot convert undefined or null to object at Function.keys

Hi everyone. I am trying to deploy a dev environment in AWS amplify of a react app with Vite and implementing CometChat ui kit for react.

when run locally everything works just fine and no errors are shown when building and deploying the environment but when starting the app it crashes inmediately with the message
“Uncaught TypeError: Cannot convert undefined or null to object at Function.keys”.

here is a sample of the code that fails when attempting to start the app:

var fv = Fi.exports.EVENTS;
Object.keys(fv).forEach(function(e) { <----------- error: TypeError Canot convert…
if (fv[e] === 0)
cv.prototype[“on” + e] = function() {
this.scope.emit(e)
}
;
else if (fv[e] === 1)
cv.prototype[“on” + e] = function(t) {
this.scope.emit(e, t)
}
;
else if (fv[e] === 2)
cv.prototype[“on” + e] = function(t, n) {
this.scope.emit(e, t, n)
}
;
else
throw Error(“wrong number of arguments!”)
});

We modified the extensions of the files from .js to .jsx for vite to be able to compile and locally it works just fine but it might have something to do with the issue.

Hi,

I am also having the same issue and found the best answer from AWS site on Amazon.

Hello @fishChipsDevTeam,

It looks like the fv object is null or undefined, and this why it says it can’t get the keys.

Could you print the fv object and check if its available? console.log(fv).