export.js: Export in all CommonJS environments

Closes #521
For this line to work when copy&pasting to the terminal I had to put an `$` at the front of the echoed string, like this:

```sh
echo -e $'#!/bin/sh\\njava -jar /opt/rhino-1.7R5/js.jar $@' | ...
```