简体   繁体   中英

Using two different versions of the same node dependency

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" } }

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://git@github.youaccount/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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM