Npm nested dependency management

I have a question about best practices for managing npm-dependent dependencies.

Let me explain my situation and please tell me what I am doing wrong, or as the best way to approach this.

I am running the application using express.js and express-mongostore in nodeenv. Due to nodeenv, I am all over the world so that they all fall into the nenv / lib / node_modules folder. The thing is, I am trying to develop the bleeding edge of express.js, while express-mongostore is not updating after some time. After installing both modules, I get this folder structure.

nodeenv / lib / node_modules / express / node_modules / connect / .. / / connect-mongodb / node_modules/ connect / ... 

So what happens is that I have two different versions of the connection.

I burned out because the cookie generated by the mongodb repository, and the one generated by the session middleware, is different in that they point to 2 different implementations of the ututils connection (one calls the repository, which calls utils and the other utils calls directly). Unfortunately, they point to different files at the time of the required resolution). The actual difference here is that they sign cookies using different algorithms. For some time, my sessions were invalid for each page load, and it took me a long time to debug to this level.

I read on the internet and it seems like this must be the way to npm and a good thing. The problem here is that since express relies on a bunch of utils in connect and connect-mongodb, it inherits some of the same classes in the connection that their different repositories are problematic.

Currently, I still have 2 versions of the connection, and I fixed one to look like the other. Obviously, this is not a sustainable solution. How can I continue and approach dependency management in this case?

Thanks in advance!

+6
source share
2 answers

You can run npm dedupe to move compatible dependencies up the tree. So, assuming express and connect-mongodb can work with the same version of connection, you get a tree like this:

 nodeenv / lib / node_modules / express / ... / / connect-mongodb / ... / / connect / ... 
+3
source

You experience a fundamental incompatibility between two modules, which assume that they can interact with each other.

This is not an NPM mistake or defect in its design. You will need to solve the problem with the logic yourself.

-3
source

Source: https://habr.com/ru/post/910569/


All Articles