Adapt main script for nodejs packaging.