feross / zelda

Automatically `npm link` all your packages together!
MIT License
283 stars 32 forks source link

Not linking #13

Closed Crispy1975 closed 8 years ago

Crispy1975 commented 8 years ago

Was using v2 and linking worked well there, finally got a chance to upgrade node to v5.5.0 and npm to v3.3 and now Zelda is on v3.1. However when running with the following...

zelda ~/Path/To/Code --production

...we end up with a symlinked node_modules folder in the ~/Path/To/Code folder and no linked modules at all. Any ideas what is going on?

This is the symlink in the code folder node_modules -> ., but no links exist anywhere else.

feross commented 8 years ago

npm3 changed the way that packages are installed (they're generally installed flat, but not always), so we needed to change our approach. Rather than trying to guess or detect when flattening happens, we just add a node_modules symlink to the ~/code folder and delete all the packages that exist in ~/code.

The Node.js require resolution algorithm works will look for node_modules folders all the way up to the root folder (/) until it finds the package it's looking for.

So, hopefully the approach makes sense. By deleting the actual packages and having a "virtual" node_modules folder with all the code in it, things should work.

However, in practice, there were some edge cases that made this not work quite right. If you have free time to debug this, a PR would be super appreciated, as I don't have time to look into this right now.

feross commented 8 years ago

This might have been fixed by https://github.com/feross/zelda/pull/14