UNPKG

unpkg is a fast, global content delivery network for everything on npm. Use it to quickly and easily load any file from any package using a URL like:

unpkg.com/:package@:version/:file

Examples

Using a fixed version:

You may also use a semver range or a tag instead of a fixed version number, or omit the version/tag entirely to use the latest tag.

If you omit the file path (i.e. use a “bare” URL), unpkg will serve the file specified by the unpkg field in package.json, or fall back to main.

Append a / at the end of a URL to view a listing of all the files in a package.

Query Parameters

?meta
Return metadata about any file in a package as JSON (e.g./any/file?meta)
?module
Expands all “bare” import specifiers in JavaScript modules to unpkg URLs. This feature is very experimental

支持多文件查询

在 url 末尾追加 /lib 路径,并且添加 ?? 查询符,添加包的版本信息及 umd 文件路径即可

查询技巧

由于云效私有镜像服务器查询很慢,所以第一次直接查询包响应会比较久,建议直接采用多文件查询的形式,这种形式会直接拉取指定包的 .tgz 文件进行解压,速度会快些