add index.js to file path if module path refer to a folder

cjs specify that if a folder is required and it contains a file named index.js, it has to be loaded.
pure-cjs give an error instead.