Function to create a JWT - Revoke Sign-In-With-Apple User Token

I’m currently trying to implement the revoke of the user token for the Sign-In-With-Apple Login correctly following the instructions I found here:
https://www.mongodb.com/community/forums/t/function-to-create-a-jwt/234997

and here:

https://github.com/Sonisan/apple-token-revoke-in-realm

But I’m failing at the point with the

“crypto’ module: error signing message”

and I don’t know exactly what’s going wrong: we now have the jsonwebtoken version set to 8.5.1 and with the algorithm ES256 - and get the error: "'crypto' module: error signing message". As far as I understand the Apple documentation here correctly, the algorithm here must be ES256, or am I mistaken here?

What else can trigger this ‘crypto’ module: error signing message" error?

Does anyone here in the community know more about this?