check existence of "path" for browser execution

The `path` only available in Node.js, should have it checked first.