Sample code for 30+ languages & platforms
Node.js

Duplicate openssl pkey -in private.pem -pubout -out pubkey.pem

See more OpenSSL Examples

How to output the public part of a private key: Demonstrates how to duplicate this OpenSSL command:
openssl pkey -in private.pem -pubout -out pubkey.pem

Chilkat Node.js Downloads

Node.js
NODEJS_PRELUDE

function chilkatExample() {

    var success = false;

    var pkey = new chilkat.PrivateKey();

    // Load the private key from an PEM file:
    success = pkey.LoadPemFile("private.pem");
    if (success == false) {
        console.log(pkey.LastErrorText);
        return;
    }

    var pubKey = new chilkat.PublicKey();
    pkey.ToPublicKey(pubKey);

    success = pubKey.SavePemFile(false,"pubKey.pem");
    if (success !== true) {
        console.log(pubKey.LastErrorText);

        return;
    }

    console.log("Success.");

}

chilkatExample();