support running main.js from anywhere

use chdir to declare the cwd of main.js, regardless of the starting
point of invocation
Merge pull request #1304 from tjwebb/master

support running main.js from anywhere