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
C:\Users\Lemons\Documents\GitHub\Pixie-beta(typescript)\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:2765
this.enumKeys = Object.keys(enumShape).filter((key) => {
^
TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at new NativeEnumValidator (C:\Users\Lemons\Documents\GitHub\Pixie-beta(typescript)\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:2765:28)
at _Shapes.nativeEnum (C:\Users\Lemons\Documents\GitHub\Pixie-beta(typescript)\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:3113:12)
at Object.<anonymous> (C:\Users\Lemons\Documents\GitHub\Pixie-beta(typescript)\node_modules\@discordjs\builders\dist\index.js:1665:24)
at Module._compile (node:internal/modules/cjs/loader:1358:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Module._load (node:internal/modules/cjs/loader:1024:12)
at Module.require (node:internal/modules/cjs/loader:1233:19)
at require (node:internal/modules/helpers:179:18)
Node.js v20.15.0
C:\Users\Lemons\Documents\GitHub\Pixie-beta(typescript)\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:2765
this.enumKeys = Object.keys(enumShape).filter((key) => {
^
TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at new NativeEnumValidator (C:\Users\Lemons\Documents\GitHub\Pixie-beta(typescript)\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:2765:28)
at _Shapes.nativeEnum (C:\Users\Lemons\Documents\GitHub\Pixie-beta(typescript)\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:3113:12)
at Object.<anonymous> (C:\Users\Lemons\Documents\GitHub\Pixie-beta(typescript)\node_modules\@discordjs\builders\dist\index.js:1665:24)
at Module._compile (node:internal/modules/cjs/loader:1358:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Module._load (node:internal/modules/cjs/loader:1024:12)
at Module.require (node:internal/modules/cjs/loader:1233:19)
at require (node:internal/modules/helpers:179:18)
Node.js v20.15.0
What am I missing here?
6 Replies
MRDGH2821
MRDGH28214mo ago
Downgrade to 5.4.5
Lemons
LemonsOP4mo ago
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 package
Favna
Favna4mo ago
Did 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?
Lemons
LemonsOP4mo ago
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 this
Favna
Favna4mo ago
urgh 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.
Lemons
LemonsOP4mo ago
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:
Want results from more Discord servers?
Add your server