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

CORRUPTS NODE_MODULES

Open Arnique opened this issue 3 years ago • 6 comments

Every time I add a new package it removes some random module from node_modules and my app breaks.

Can't use this anymore for this reason. Pretty cool though when it works.

Arnique avatar Oct 07 '20 10:10 Arnique

Encountered this, too. Upon every new install, it most if not all installed modules (but keeps them in package.json). So after every npm intall some-moudle, I have to run npm install again. The preinstall script does not help as it only triggers before a plain 'install'. Why does this happen?

ghost avatar Mar 16 '21 13:03 ghost

to fix this, merge this:

{
  "scripts": {
      "postinstall": "link-module-alias",
  }
}

into your package.json file ;)

devthejo avatar Mar 21 '21 12:03 devthejo

That does not work for me. I added both the "preinstall" and "postinstall" scripts as per the readme and I am still having the same issues as these other guys. E.g. any time I npm install some-module or npm uninstall some-module, it almost purges the "node_modules", while informing me that it had "removed <a metric ton of> packages and audited <a few> packages". The only way to bring them back is to run plain npm install.

Papooch avatar Mar 22 '21 07:03 Papooch

are you using @ as an alias ? If this is the case it could be the reason of your problems, as indicated in the readme. Otherwise, I don't know, personally this is the way I'm using it and I never had bugs:

{
  "_moduleAliases": {
      "~": "src",
      "~public": "public"
    },
}

devthejo avatar Mar 22 '21 08:03 devthejo

I am using #, maybe that causes issues, too? I will try the tilde and report back.

P.S. I tried @ initially, but that nukes the repository irreversiby, even deleting the .git folder. The current issue is more mild.

Papooch avatar Mar 22 '21 08:03 Papooch

@Papooch did u try? can you please explain the exact steps to successfully use "link-module-alias"?! I am trying to write an article about it and need confirmation (I know I should do it myself but I am a student and right now I am not doing any project which needs this, so I have to ask someone who is actively using this.)

tripathi-abhishek avatar Apr 14 '21 12:04 tripathi-abhishek