Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using two different versions of the same node dependency

Tags:

node.js

npm

Is there a way to include two versions of the same dependency in nodejs package.json?

For testing purposes, I need to use two versions of socket.io (one to expose a socket in the latest version and one to simulate a dependency server using an old release).

{ "dependencies": { "socket.io": "~0.9.0", "socket.io": "~1.2.0" } }

like image 359
yves amsellem Avatar asked Nov 06 '14 14:11

yves amsellem


1 Answers

Maybe not the best solution, but you can first fork socket.io 0.9 on github: https://github.com/Automattic/socket.io/tree/0.9

To create https://github.com/youaccount/socket.io/tree/0.9

Then use this:

"dependencies": {
    "oldsocket.io": "git+ssh://[email protected]/socket.io.git#0.9",
    "socket.io": "~1.2.0"
}

Edit the package.json and rename the name attribute to oldsocket.io

And you can now require socket.io or oldsocket.io

like image 158
KyleK Avatar answered Oct 08 '22 16:10

KyleK