Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–223 runs
build_error
glibcnode 18–223 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
cdn
✓ import { cdn } from 'vite-plugin-cdn2'
✗ const cdn = require('vite-plugin-cdn2')
ESM-only; CommonJS require will fail.
default
✓ import { cdn } from 'vite-plugin-cdn2'
✗ import cdn from 'vite-plugin-cdn2'
No default export; only named export 'cdn'.
type IModule
✓ import type { IModule } from 'vite-plugin-cdn2'
✗ import { IModule } from 'vite-plugin-cdn2'
IModule is a type; use 'import type' to avoid runtime inclusion.
Shows how to replace Vue and React modules with CDN links in Vite config.
// vite.config.ts
import { defineConfig } from 'vite';
import { cdn } from 'vite-plugin-cdn2';
export default defineConfig({
plugins: [
cdn({
modules: [
{ name: 'vue', var: 'Vue', path: 'https://unpkg.com/vue@3/dist/vue.global.prod.js' },
'react'
]
})
]
});
Errors
Common errors & fixes
Error: Cannot find module 'vite-plugin-cdn2'
Package not installed or typo (missing '2').
fixRun 'npm install vite-plugin-cdn2 -D' and import correctly.
TypeError: cdn is not a function
Default import used instead of named import.
fixUse 'import { cdn } from 'vite-plugin-cdn2''. Uncaught SyntaxError: The requested module 'vite-plugin-cdn2' does not provide an export named 'default'
Default import used when only named export exists.
fixChange import to named: 'import { cdn } from ...'. Error: [vite] Internal server error: Cannot read properties of undefined (reading 'transform')
Plugin applied incorrectly (likely missing 'apply' or placed after Vite built-in plugins).
fixEnsure plugin is placed before built-in plugins and 'apply' is set correctly.
Audit
Dependencies
viterequiredThis is a Vite plugin; requires Vite as a peer dependency.