improve invocation chain; main module will fallback to <name>.js; #10; related to cortexjs/cortex#415
fixes the weird cases that require.resolve will change the path of temp directory; #10