ilearnio / module-alias

Register aliases of directories and custom module paths in Node
MIT License
1.76k stars 69 forks source link

Bug: require loads local file instead of node_modules package #25

Open ruzicka opened 6 years ago

ruzicka commented 6 years ago

It seems that when there is a local file called the same as an existing package (let's assume stripe package and stripe.js file) and you are trying to load the package, local file is loaded instead.

require('stripe') // loads local stripe.js file

expected behaviour:

require('stripe') // should load `stripe` package
require('./stripe') // should load local stripe.js file
ilearnio commented 6 years ago

Hm, I'm not sure if it's caused by module-alias but will check it

ellell commented 6 years ago

I'm having a similar issue, getting an error because it's trying to get a local file instead of dependency. Issue only happening when I define aliases in package.json and import module-alias/register, not when calling .addAliases() directly.