-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This deleted all my source files? #3
Comments
I'm testing but I believe the pre-install script is what would have prevented this.
|
Wow, this sounds bad. Can you show me the structure of your project? Btw. just yesterday I discovered that it's possible to link subdirectories via a |
Can you elaborate? I am not sure I understand.
|
Clone this repo and try the steps below. Not sure if this also happens with npm, just wanted to get this to you ASAP. ➜ delete-bug git:(master) rm -rf node_modules
➜ delete-bug git:(master) yarn
yarn install v1.12.3
warning package.json: No license field
warning No license field
[1/4] 🔍 Resolving packages...
[2/4] 🚚 Fetching packages...
[3/4] 🔗 Linking dependencies...
[4/4] 📃 Building fresh packages...
$ link-module-alias
[####################] 20/20link-module-alias: @components -> ./components
✨ Done in 0.80s.
➜ delete-bug git:(master) node main.js
TEST_COMPONENT
➜ delete-bug git:(master) yarn add fuse.js
yarn add v1.12.3
warning package.json: No license field
warning No license field
[1/4] 🔍 Resolving packages...
[2/4] 🚚 Fetching packages...
[3/4] 🔗 Linking dependencies...
[4/4] 📃 Building fresh packages...
warning No license field
success Saved 1 new dependency.
info Direct dependencies
└─ fuse.js@3.3.0
info All dependencies
└─ fuse.js@3.3.0
$ link-module-alias
link-module-alias: @components -> ./components
✨ Done in 0.82s.
➜ delete-bug git:(master) ✗ node main.js
file:///Users/xo/code/delete-bug/index.js:1
Error: Cannot find module '@components'
at Object.Module._extensions..js (internal/modules/cjs/loader.js:734:10) |
PING @Rush |
@OmgImAlexis I ran your steps - very helpful! .. and it looks like it's a bug in yarn ... I'll investigate it further |
@OmgImAlexis it's not a permanent solution but this would help avoid this particular issue:
|
@OmgImAlexis the upstream bug is #5709 I added a comment to that issue thread: |
@OmgImAlexis the thread seems to indicate that another workaround is not using |
This happened to me a few times in the last week and it took me a while to understand that using yarn with |
@josecarneiro this patch does fix the issue. |
I added it to my Thank you @OmgImAlexis and @Rush! |
Well, it did happen again after running |
This looks related. Possibly a bug? |
Is not using |
@Rush I'd prefer if we could keep using it. Any chance |
I find that using ´@´ is one of the great appeals of this module. Wanting to keep consistency between my backend codebase and my webpack-built client side app is the reason I researched this topic and consequentially found ´link-module-alias´. Changing the alias is a possibility. |
@Rush Having the preinstall hook do a |
I want to add to @shawncplus 's comment that this does not seem to be yarn-related at all, since it deletes files in plain npm as well. |
Uh, I wasn't lucky enough to be aware of this issue before it deleted my day of work. I always forget to commit more frequently 😄 |
Have you tried naming your modules without the |
"module-alias" was not working with the ESLint, so installed this one. This module worked perfectly. And the moment I ran "yarn remove module-alias", everything in my project directory got deleted including .git I just have just package.json and yarn.lock in directory (and the aliased directory @utils - empty). My local commits got lost, several hours of work. Cool! If this module has an issue, please add a big RED BOX on the npm page that this can potentially wipe the whole directory. |
I am very sorry you've lost your work. :-( Can you share the setup that caused everything to disappear? We can then prevent doing this particular set up or at least warning against it. |
@Rush, I don't have anything because everything got wiped. So, here is the explanation - no code.
"_moduleAliases": { ESLint was not working with "module-alias" package, so I installed this one (yours) and ESLint worked. Then the moment I ran yarn remove module-alias, everything got deleted (not even in the Trash). I came to know that there is an issue with this module after it, if you could please add some warning with a link to this issue, it will be really helpful. I'm ashamed that I had not pushed my work on GitHub. BTW, I'm on Linux 18.04.2. |
There's no need to be ashamed @mfaheemakhtar, you're in good company based on this thread. I second the idea of a huge warning on the NPM page for this module, or even unpublishing it, until the issue is resolved. |
@seanohue @mfaheemakhtar added the warning. Let me know if you guys think it's sufficient ... |
I think I will add a warning at runtime that discourages the use of modules starting with |
I think that's a good idea! Perhaps even throw an error if they use such an alias. I'm willing to make a PR that does this. Thanks for being so responsive with this issue. |
@OmgImAlexis I don't want to make a useless debate, but let me just make it clean. @misamisa23 already knows he or she should use other aliases rather than '@'. Thus, @misamisa23 would be able to use link-module-alias without such an issue. That's it. So, it just doesn't make sense to tell him/her not to use it. |
Well, I had that problem yesterday! I lost my source files too. Luck of mine I have a repository in Bitbucket but I lost my .env that I will have to configure once again. It could be worse. I was warned but it doesn't justify the issue. It happened when I tried to install the module Edit: It is clear that is not a Operating System Issue, i tried the same thing in Windows and it deleted even my .git folder. Really, there's no way to prevent this? We have the evidences, what we need to fix that issue for once and for all for the sake of the good operation of the npm modules? They should not be risky but safe. We need to investigate and fix! |
@lwxbr Please read the conversation. We know what's the root cause of this issue and it's how |
@sarneeh, and how you will fix it then? For me it is not clear that it is already solved. It is showing a warning that I should not use @ for alias and that's it. I'm using yarn 1.19.1 and link-module-alias 1.2.0, just update them will not solve the issue! |
@lwxbr As you can see this issue is not solved as it is in |
@sarneeh, thanks for explanation! I think that issue should be closed if it is a yarn issue. But the module should create a workaround, at least one thing to prevent the deletion of the modules (that is ugly). The questions were answered? No, they aren't in the documentation of the project. That should be there, not here hidden in a issue not resolved. |
i have same problem while |
Agreed. Would you mind sending a PR to change the README file? |
A README update still doesn’t fix this issue though. This should be the default case. This is still a danger to users that haven’t committed code. I lost a whole day worth at least a few times that’s hundred of dollars of wasted time. |
Ok, let's put it to rest then. What is the proposed solution? For some reason people want to keep using Should the warning be larger? Should it be a prompt? I don't advise using |
I'd suggest disabling the use of the issue causing code until they enable an option that clearly states what can happen. It shouldn't be so easy for this to happen. |
I'm experiencing the same problem even if I'm using package.json
When I'm doing EDIT: |
I managed to reproduce this issue, even with this solution. I can't provide a testing environment, because it's a project related to workplace. So basically this project uses multiple themes (let's give them random names: classic, acme, supernova) and shares a common JS files in the build process.
What happened:
I think that Sure, it's pretty rare to have
I think this is bloated. Is there any alternative to this, which is cleaner? |
@pankajvaghela not sure that solves the issue. Where else would they go? If not in node_modules than how exactly is the node require system meant to find them? |
yeah my bad, figured it, after commenting. Maybe we can make symlinks say in folder A. make wrapper file to export everything from there and then have that symlinked to node_modules? |
The issue is intellisense and module resolution. The issue really needs to be fixed on the npm/yarn side. |
For any of y'all using Typescript. This article here gives a good solution for path aliases by configuring |
- This was causing the source dir deletion. Rush/link-module-alias#3
With typescript I solve it with this solution by using tsconfig-paths |
So, like many others, I did not read the issue fully and thought that it only affects |
I have the same error and also lost most of the src code. I'm using |
@Rush What about letting the program print an error message and just exit when it finds |
I've had this just happen to me when using |
gosh, this package delete all my day work... This package need a serious update in readme file, please remove example with @ and put a big and clear text about this issue. DO NOT USE @ IN ALIAS! |
If anybody has a good idea how to update the README or code to avoid the issue please send a PR. I tried to add the warnings already |
Why not remove the ability to use it? That might be the best option here. |
…oss due to link-module-alias WARNING! Using @ in front of your module name @nestjs-geteventstore may cause data loss. Please read this issue thread Rush/link-module-alias#3 and make a backup before executing any npm/yarn commands. The issue ultimately can be blamed on npm/yarn. You've been warned.
So I used yarn as usual to add a new dependancy and from the looks of it all my source that was symlinked via node_modules was removed.
Lucky I had just committed and could use git to retrieve the files but this looks like a huge issue.
PING: @Rush
The text was updated successfully, but these errors were encountered: