It is likely that the module you are using is depending on a native library. For example, pem
is a wrapper around the openssl
executable which will fail if it's not available in the path.
If this is the case, you could use a pure js library like forge which has no such native dependencies. It is capable of generating self-signed certificates as well.