A professional open-source Node.js CLI tool to instantly get CDN links for any npm package from major providers.
- Auto-discovers UMD files from CDN file listings (unpkg, jsDelivr)
- Supports unpkg, jsDelivr, esm.sh, skypack
-
Minified/dev toggle:
--min
(default) or--dev
- Batch mode: Query multiple packages at once
-
Clipboard: Copy first CDN link with
--clipboard
-
JSON output:
--json
for machine-readable output -
UMD-only:
--umd
for just unpkg/jsDelivr UMD links -
Show all versions:
--versions
flag -
Verbose/silent:
--verbose
for debug,--silent
for CI - Graceful error handling
npm install -g npm-to-cdn
n2cdn react
n2cdn lodash@4.17.21
n2cdn axios --json
n2cdn vue --clipboard
n2cdn react@17 lodash@4.17.21 --json --silent
n2cdn react --versions
n2cdn react@17 --umd --verbose
n2cdn vue@2 --dev --umd
n2cdn react --cdnjs
n2cdn react --statically user/repo/tag/dist/file.js
n2cdn react --bowercdn
n2cdn react --template "https://mycdn.com/{name}@{version}/{file}"
-
--json
Output as JSON -
--clipboard
Copy first CDN link to clipboard -
--umd
Show only unpkg/jsDelivr UMD links -
--min
Prefer minified builds (default) -
--dev
Prefer development (non-minified) builds -
--versions
List all available versions for the package -
--verbose
Show all attempted URLs and debug info -
--silent
Suppress banner and only output links -
--help
Show help
Only valid CDN links are shown. UMD guessing is version-aware and auto-discovers from CDN file listings.
- unpkg
- jsDelivr
- esm.sh
- skypack
- cdnjs
- Statically (GitHub, GitLab, Bitbucket)
- BowerCDN
- Custom templates
n2cdn react --cdnjs
n2cdn react --statically user/repo/tag/dist/file.js
n2cdn react --bowercdn
n2cdn react --template "https://mycdn.com/{name}@{version}/{file}"
- All provider flags are now grouped and clearly documented
- Input validation for statically flag
- Consistent flag naming and help output
$ n2cdn react@17 lodash@4.17.21 --json --silent
[
{
"pkg": "react",
"version": "17",
"cdns": {
"unpkg": "https://unpkg.com/react@17/umd/react.production.min.js",
"jsDelivr": "https://cdn.jsdelivr.net/npm/react@17/umd/react.production.min.js",
"esmSh": "https://esm.sh/react@17",
"skypack": "https://cdn.skypack.dev/react@17"
}
},
{
"pkg": "lodash",
"version": "4.17.21",
"cdns": {
"esmSh": "https://esm.sh/lodash@4.17.21",
"skypack": "https://cdn.skypack.dev/lodash@4.17.21"
}
}
]
This CLI is globally installable. After running:
npm install -g npm-to-cdn
You can use the n2cdn
command anywhere.
MIT
- Support for more CDN providers
- Custom CDN URL templates via CLI flag
See CONTRIBUTING.md for how to get started.
This project follows the Contributor Covenant Code of Conduct.