TIL you can add multiple versions of a NPM package

Oliver Peate posted on October 8th, 2019

Problem: You have Bootstrap 3.x in a project but need to add version 4.x too.

Solution: You can add packages with an alias using yarn:

# Syntax:
# yarn add <alias-package>@npm:<package>@<version>

# Example:
yarn add bootstrap-v4@npm:bootstrap@4.3.1

The resulting package.json (abridged):

  "dependencies": {
    "bootstrap": "^3.4.1"
    "bootstrap-v4": "npm:bootstrap@4.3.1",

What did you learn today?

Write a quick TIL post to reflect on what you've learned.

Write a post