How parse a Certificate Signing Request (CSR) file with Javascript to get the subject?

I read a Certificate Signing Request in X.509 format. I have tried to parse it with the class X509Certificate from NodeJS ‘crypto’ library.
The input format is a string


I want to get the subject from this certificate signing request (CN, emailAddress, C,…)

I tried the following code

const { X509Certificate } = await import('crypto');
const x509CSR = new X509Certificate(pem)

But the the following error is displayed:

error:0909006C:PEM routines:get_name:no start line

So I have tried another library called ‘node-forge’.

const { pki } = await require('node-forge');
x509CSR = pki.certificationRequestFromPem(pem);

But the the following error is displayed:

Cannot read public key. OID is not RSA.

How to get the subject data from the certificate signing request in a NodeJS server?