Package Alias: Multiple versions of npm package

Fahim’s text explains how to manage package versions when creating modules or plugins. Users can create custom aliases using npm to install specific package versions, such as “astro-v1” or “astro@1”. This allows for compatibility across different versions of the packages being used.
generated by gemma3:4b

When you are working on a module/plugin and want to make sure that they work with all versions, you can work with a custom alias.

Table of Contents

Custom Alias

Terminal window
npm i <your-alias>@npm:<package-name>

Specific Version

You can also install a specific version of the package by appending the command with @<package-version>.

Terminal window
npm i astro-v1@npm:astro@1
npm i astro@npm:astro

Import usage:

// astro-v1
import { defineConfig } from "astro-v1/config";
// astro
import { defineConfig } from "astro/config";