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 🙏

© 2026 – Pkg Stats / Ryan Hefner

liudcfirstdemo6

v2.2.3

Published

第一个demo

Downloads

4

Readme

npm

JavaScript/Node.js默认包管理工具。类似pip、composer等等包管理工具。

每个包管理工具都有一个中心仓库,npm包的中心仓库(https://www.npmjs.com)。所说的‘包’是个人或组织上传到仓库中的模块,每个模块可提供给其他开发者下载使用。

npm的使用

使用NPM包管理的必要文件包括packag.json、packag.lock.json、node_modules文件夹

npm install lodash

package.json和package.lock.json的关系 package.json是包管理的清单列表。 package.lock.json是通过清单列表输出更详细的详细清单列表。lock文件的存在是为了防止在A运行或开发时能跑,在B运行开发时因为小版本更新导致无法使用的问题。 node_modules的内容是根据package.json所下载(npm install)的最终产物。

使用npm管理包时需要有一个必要的文件package.json package.json生成方式有使用命令npm init及手动创建生成。

npm config 设置一些参数

npm install --save

npm install --save-dev

缓存列表、缓存清除、缓存地址,为什么清缓存

当执行npm **执行命令时在终端做了什么事儿?

npm -v查看 在终端输入npm时系统会

当node下载完成后,会将node、npm等携带的可执行文件默认放入/usr/local/bin中,echo $PATH查看具体可执行文件列表。

终端输入npm命令- 解析系统PATH从左到右查询哪里有可执行npm文件- 使用nodejs执行这个npm.cli.js文件- npm.cli引擎启动- npm的参数解析- 解析依赖关系(A包使用C包的版本是1.0.0,B包使用C包的版本是2.0.0。去找匹配满足所有包的版本,如果找不到就下载一个包的多个版本,嵌套包)- node_modules差异计算(计算需要更新、删除、增加的包)- 根据差异计算从registry镜像地址中下载(如果本地有缓存就从本地取)- 解压到node_modules中- 更新package.lock.json-

^:允许兼容到次版本、修订版本。当update时,可更新次版本、修订版本。(例:@2.2.9、@2.3.1。不允许更新主版本) ~:允许兼容修订版本,当update时,可更新修订版本。(例:@2.2.2、@2.2.9。不允许更新主版本、次版本) 固定版本:在版本号前不使用通配符时为固定版本,当update时不允许更新。

使用

which npm 查询npm可执行文件 windows 是npm.cmd文件

name包名 version版本号 description包描述 keywords搜索关键字 homepage项目主页 homepage包主页 bugs报bug的地方地址、邮箱 license包许可证(MIT) author作者信息 main CommonJs入口地址 module ES Module 入口 types Ts类型生命文件入口 dependencies 运行时需要的依赖 devDependencies 开发时需要的依赖 peerDependencies 宿主的依赖要求 optionalDependencies 可选依赖 engines限制node、npm的版本 repository 仓库信息{ "type": "git", "url": "..." }

1.npm包管理(包使用)

必要文件生成package.json

多种生成方式
1、npm init 或 npm init -y
2、npm install 包名@版本号 自动生成package.json

package.json 参数讲解

参数讲解
通配符讲解(~、^、>....)

package.json与package.lock.json的关系

.npmrc 讲解

常用配置参数讲解

npm config npm配置

(官方镜像:https://registry.npmjs.org)
(原淘宝镜像:https://registry.npmmirror.com)
(私有化部署镜像:https://npm.epatient.cn)

包的下载、卸载和更新

npm install 包名版本号
npm uninstall 包名版本号
npm update 包名版本号

运行script中脚本

可简化命令与自定义命令运行

npm cache 清除缓存

npm cache ls 查看缓存列表
npm cache clean --force 清空缓存列表

npm包发布

登录:npm login
发布:npm publish
删除已发布:npm unpublish <包名>@<版本号> --force

2.包管理扩展

npm 生态全面,兼容性好,node自带不用安装。

pnpm 速度快,包安装到全局~/.pnpm-store/,通过硬连接访问。项目中node_modules中通过符号记录来访问全局的store。

yarn 极致速度,v2版本没有node_modules,包在.yarn/cache/*.zip。通过.pnp.cjs管理依赖解析。老包兼容性差,有些编译器需要增加配置识别.pnp.cjs。