support running main.js from anywhere

use chdir to declare the cwd of main.js, regardless of the starting
point of invocation