detect index.js module in dirs properly