module-alias icon indicating copy to clipboard operation
module-alias copied to clipboard

Project with module-alias cannot be used as dependency

Open ShenChen93 opened this issue 5 years ago • 3 comments

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 Screen Shot 2019-08-19 at 11 53 14 AM

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

ShenChen93 avatar Aug 19 '19 18:08 ShenChen93

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 ?

Kehrlann avatar Aug 20 '19 10:08 Kehrlann

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

ShenChen93 avatar Aug 20 '19 23:08 ShenChen93

Mmmh to be honest I don't have the bandwidth either, and it's a big-ish change

Kehrlann avatar Aug 22 '19 12:08 Kehrlann