module-alias
module-alias copied to clipboard
Project with module-alias cannot be used as dependency
Hi There,
Recently, I met some issue while using module-alias. The use case is: I have two nodejs package A & B. Here is the package A aliasTest.zip, which use module-alias and register '@handler' as './lib/src/handler'. The pacakge A works well singly, but, if I want to use A as a dependency of package B, something went wrong. For better reproduce: I just put A in B's node_moudles. Then in B's package.json, I add scripts
"scripts": {
"print": "node node_modules/aliasTest/print.js",
},
However, when i use npm run print
, the error message is
PS: I save module alias as package B's dependency as well Can someone give me some guide on how to resolve this issue ?
Thanks, Shen
Hi ! Thanks for reporting this. Unfortunately this is a known limitation of module-alias, it cannot be used within dependencies. There's an outstanding issue for this: #35 . Are you interested in working on a PR ?
Hi @Kehrlann,
Thanks for replying. Sorry, I don't have the bandwidth for a PR, although I am really interested in how module alias works. I wonder if you guys have any plan to fix #35 ?
Thanks, Shen
Mmmh to be honest I don't have the bandwidth either, and it's a big-ish change