Due to https://github.com/npm/npm/issues/2943, npm will never support the ability to alias packages and install multiple versions of the same package.
The workarounds posted on the github issue might work for pure-JS modules, but as npm becomes a standard for frontend package management, packages now include various assets such as CSS.
Is there any workaround to install multiple versions of the same package?
The best idea I've come up with is to "clone" a package, and publish it with a slightly different name.
For example, if you need multiple versions of jquery
, you could just publish packages called jquery-alias1
, jquery-alias2
, jquery-alias3
etc, and then set the appropriate versions in your package.json
.
Or you could name the packages according to their version number, eg jquery-1.11.x
, jquery-2.1.x
, etc..
Both of these approaches seem sloppy though. Are there better ones?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…