npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@steedos/ee_unpkg

v1.0.0

Published

The CDN for everything on npm

Downloads

26

Readme

UNPKG · Travis

UNPKG is a fast, global content delivery network for everything on npm.

Documentation

Please visit the UNPKG website to learn more about how to use it.

Getting started

nvm use 14
yarn install
yarn build

export PORT=8080
export NPM_REGISTRY_URL=https://registry.npmmirror.com

yarn start

访问 http://127.0.0.1:8080/

Build Docker

docker build --tag steedos/steedos-unpkg .
docker run -p 8080:8080 -d steedos/steedos-unpkg 

Base URL

设置基础URL,用于访问UNPKG服务。

export UNPKG_BASE_URL=/unpkg/

此时需访问 http://127.0.0.1:8080/unpkg/

白名单

限制CDN服务器只能访问指定的包。

export UNPKG_WHITE_LIST=react,@steedos,lodash
  • 环境变量用于控制允许访问的包关键词,用逗号隔开。
  • 任何包只要包含其中任何一个关键词都可以访问。
  • 如果未配置环境变量,则不做任何限制。

远程NPM仓库

设置远程NPM仓库,UNPKG将从此仓库下载软件包。

NPM_REGISTRY_URL=https://registry.npmmirror.com

NPM 缓存

可以在本地文件夹中缓存npm信息。

  • NPM_CACHE_ENABLED 启用缓存。
  • NPM_CACHE_FOLDER 缓存文件夹的路径,默认为 caches 子文件夹。
  • NPM_CACHE_PACKAGE_INFO 自动保存软件包信息到本地缓存。启用此参数,软件包版本更新后,无法获得最新的信息。
  • NPM_CACHE_PACKAGE_CONTENT 自动保存软件包内容到本地缓存。
DEBUG=1
NPM_CACHE_ENABLED=true
NPM_CACHE_FOLDER=/caches/

纯内网环境使用CDN

如果服务器不能访问外网,可以按以下步骤操作,使用本地缓存。

  1. 在内网环境启动服务;
  2. 配置 NPM_CACHE_ENABLED 相关环境变量;
DEBUG=1
NPM_CACHE_ENABLED=true
NPM_CACHE_FOLDER=/caches/
  1. 参考 自动更新缓存文件夹 在联网服务器上启动服务并缓存资产包到/caches;
  2. 将联网服务器上缓存的caches文件夹拷贝到内网环境中并替换本地的caches文件夹;

手工更新缓存文件夹

在可以访问公网的服务器上用脚本,生成 /caches/ 文件夹,复制到内网环境。

注意,@organization/package 格式的软件包,需要保存为 @organization_package

cd /caches/
curl -o react.json https://registry.npmjs.com/react
curl -o react-18.2.0.tgz https://registry.npmjs.com/react/-/react-18.2.0.tgz
curl -o @steedos-widgets_amis-object.json https://registry.npmjs.com/@steedos-widgets/amis-object
curl -o @steedos-widgets_amis-object-1.1.6.tgz https://registry.npmjs.com/@steedos-widgets/amis-object/-/amis-object-1.1.6.tgz

自动更新缓存文件夹

在可以访问公网的服务器上启动服务,访问需要缓存的软件包版本,生成 /caches/ 文件夹,复制到内网环境。

NPM_REGISTRY_URL=https://registry.npmmirror.com
NPM_CACHE_ENABLED=true
NPM_CACHE_FOLDER=/caches/
NPM_CACHE_PACKAGE_INFO=false
NPM_CACHE_PACKAGE_CONTENT=true

与华炎魔方集成

配置环境变量指向本服务,可以启用此服务作为华炎魔方内置的CDN服务。

STEEDOS_UNPKG_URL=http://127.0.0.1:8080