node-forward / discussions

Soliciting ideas and feedback for community driven collaborative projects that help Node.
149 stars 1 forks source link

Having packages reference root packages instead of installing dependencies locally. #27

Closed mrbeardy closed 9 years ago

mrbeardy commented 9 years ago

Edit I was wrong about duplicate packages, I just ran a test and a package didn't install a dependency when I already had the exact version. Still, I guess this could be a discussion on cleaner folder structure, though duplicate packages was my main issue.

I'll close this issue tomorrow if there's no discussion.

Question This post pretty much depends on how io.js will handle packages. If it's going to handle them in the same way as npm and node, then this post is relevant. If not, how will it be handling them?

TL;DR Can't packages be installed in node_modules (or io.js's equivalent) with the version appended to the folder name, then any requests for that package will check if it's already installed and if not, install it at root?

Disclaimer I've never really delved deep into the source code for Node, so this question/discussion is coming from a naive user. Feel free to correct anything in this post or close it if it's not constructive, just looking for a discussion really. It's also probably been discussed before, but I couldn't think of the right things to search for.

Problem One thing that I always found strange about node's approach to package management was how each package had it's own folder for dependencies, and those dependencies having their own folder, and so on, which led to some projects having tons of sub-folders and possibly tons of duplicated packages making the node_modules folder pretty large in size. See edit above

Suggeston I'd guessed a reason for this was to get around the problem of each package requiring a specific version of their dependencies, but wouldn't it be more practical to have each package installed into the root (i.e node_modules) folder and the version number appended to the folder name? Meaning if package A requires Z-1.0.0 and package B and C require Z-1.0.3, both versions would be installed at the root and any packages that required a specific version would just check in the root for their version or install it if it doesn't exist yet.

Meaning you end up with this:

/root
    /modules
        /A-1.0.0
            depends on "Z-1.0.0"
        /B-1.0.0
            depends on "Z-1.0.3"
        /C-1.0.0
            depends on "Z-1.0.3"
        /Z-1.0.0
        /Z-1.0.3

Instead of this:

/root
    /modules
        /A-1.0.0
            /modules
                /Z-1.0.0
                    /modules
                        /...
        /B-1.0.0
            /modules
                /Z-1.0.3
                    /modules
                        /...
        /C-1.0.0
            /modules
                /...

Again, sorry if this was pretty naive and has been discussed a lot before, just trying to understand the reasoning behind the decision for local dependencies.