TypeError: Cannot convert undefined or null to object
I get this error after trying to run my build (Typescript) - it only happened when I updated my typescript package to 5.5.4
What am I missing here?
6 Replies
Downgrade to 5.4.5
I'll try it when I get home
and sadly it didn't work so I'll try to check whether it's for
@discordjs/builders
receiving wrong InteractionContextType
or something
but I highly doubt it's that since it was running perfectly fine before I updated the typescript packageDid you set it to ^5.4.5? Because that will still install 5.5.4 as per caret semver rules.
Anyway this is a runtime error it looks like so I doubt it's TS anyway.
The error is saying that enumShape is undefined or null. What exactly is enumShape? Code of yours?
nope, I manually removed it firstly then installed it using
npm install [email protected]
and removed the ^
so it doesn't update it later on
nope, it's coming from node modules which is why I'm confused about it
I'll still try to check my code and see since it could be something else. I'll check and update you on thisurgh uhm
the only other idea I got is there is some clash of CJS vs ESM but both builders and shapeshift co-ship CJS and ESM files and target them accordingly so if your Node version is up-to-date (anything in the 20.x or 22.x range) then that should be fine, assuming all your projects file extensions are consistent. That is to say, you either use only
-
.js
, .ts
, .cjs
, or .cts
or
- .js
, .ts
, .mjs
, or .mts
but not a mix of those.
And of course setting the "type": "..."
accordingly in the package.json. Especially if you're writing ESM.Turns out it was caused by an override of an older package for
discord-api-types
I was using InteractionContextType
in my commands structure which happened to exist only in version ^0.37.84 (while I had 0.37.20)
The error was conducted by discordjs/builders package so it's not related to sapphire
Thanks for the help and sorry for causing a fuss about this error :kannaHeart: