[英]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? 有没有办法在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). 出于测试目的,我需要使用两个版本的socket.io(一个用于公开最新版本的套接字,另一个用于使用旧版本模拟依赖服务器)。
{ "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 也许不是最好的解决方案,但你可以先在github上分叉socket.io 0.9: https : //github.com/Automattic/socket.io/tree/0.9
To create https://github.com/youaccount/socket.io/tree/0.9 创建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
编辑package.json并将
name
属性重命名为oldsocket.io
And you can now require socket.io
or oldsocket.io
你现在可以要求
socket.io
或oldsocket.io
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.