-
Notifications
You must be signed in to change notification settings - Fork 7.3k
My 2 cents on modules #25770
Comments
I guess the biggest problem here is that many of us are afraid of introducing this method, since it will break compatibility if a module needs an older version of another module. And I know that this is really important for you. But why don't we just make "latest" the default when requiring? And if a module needs a specific older version of another module, it needs to specify the version tag when requiring it within the code. |
Definitely appreciate the discussion, but this kind of discussion is better directed at either the https://github.com/nodejs/io.js |
Actually, it'd be best to discuss this in N(ext) G(en): https://github.com/nodejs/NG than io.js, but it's probably also a topic for npm, however the npm issue tracker is lready busy enough as it is, so I suggest NG. bottom line: we can't just change modules, but maybe in some future. |
First off: I'm relatively new to node (started developing with it a few months ago). I'm not yet one of those experienced professionals in this area, so please don't take my arguments to seriously. I'm just trying to describe what bugs me about the way, how modules in node currently work.
I started developing a secret project a while ago and I've immediately figured out that this is one of the major things which prevents me from bringing some logic in the structure of the project. And that's exactly why I'm here now and want to talk about this.
When talking about open source projects, I'm usually very concerned about doing stuff the way how it was intended by it's creators (since that mostly leads to clean code and a faster development process). I'm also very happy about the fact that there are many people out there who are contributing to the openness and trying to make the standards easy to understand, so that new users like me can quickly get started without needing to think about their own structure.
Anyway. Let's talk about the problem: To me, it feels like the logic behind the way how modules are intended to be structured within apps, isn't that awesome. When installing a module (or "package", if you want), the developer usually has the choice between installing it within the app's directory (then it will be put in the "node_modules" folder) or setting it up globally using the
-g
parameter when installing.Problems and their solution
Why don't we just install all modules globally by default? And if a module needs to require it, it will simply be loaded from that global directory where all modules live. Some advantages this method will entail:
More specific: If a module depends on other modules, NPM will still install those automatically if they're listed within the
package.json
file - just globally (by default), rather than locally.I'm not sure but I think we also wouldn't be the first ones implementing this method. Just think about how Ruby does it with Gems. They're all in one place. No nesting, no confusion.
So what do you think about this? Aren't you also tired of this never ending story of modules that are nested to the moon?
The text was updated successfully, but these errors were encountered: