Technically, the answer to your question is no , given your limitations. npm is going to install the dependencies for this package.json file in the same node_modules directory, and thus the file system itself will prevent two versions of the same package from being in the same directory. However, there are many workarounds. You can create a tiny laying module that simply depends on the express version of v3 and provides the express v3 module, and then use it in that part of the application that requires v3.
You can also do what the node community culture offers and divide the application into small parts. This is a clear trend in node - smaller modules are better. Express also makes this pretty easy, as it supports installing a child application in the parent application.
You can also play some tricks using npm link and symbolic links and that make it convenient to work with code from two different modules at the same time.
source share