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

npm-lifecycle-scripts

v1.0.0

Published

A demonstration project showing npm lifecycle hooks in action

Readme

npm Lifecycle Test Project

这是一个用于测试和演示npm生命周期钩子的项目。通过这个项目,您可以了解npm在不同操作过程中如何自动触发各种生命周期脚本。

项目结构

  • package.json - 包含所有生命周期脚本定义
  • index.js - 主应用程序入口点

生命周期脚本列表

本项目包含以下npm生命周期脚本:

安装相关

  • preinstall: 包安装前执行
  • install: 包安装时执行
  • postinstall: 包安装后执行

发布相关

  • prepublish: 包发布前执行
  • publish: 包发布时执行
  • postpublish: 包发布后执行

测试相关

  • pretest: 测试运行前执行
  • test: 运行测试
  • posttest: 测试运行后执行

启动相关

  • prestart: 应用启动前执行
  • start: 启动应用
  • poststart: 应用启动后执行

构建相关

  • prebuild: 构建前执行
  • build: 执行构建
  • postbuild: 构建后执行

版本控制相关

  • version: 更新git标签时执行
  • postversion: 更新git标签后执行

自定义测试脚本

  • life-test: 运行完整测试周期(pretest → test → posttest)

使用方法

1. 运行测试周期

npm run life-test

这将依次执行pretest、test和posttest脚本。

2. 运行测试

npm test

这将运行test脚本以及关联的pretest和posttest脚本。

3. 启动应用

npm start

这将启动应用并执行相关的生命周期脚本。

4. 运行构建

npm run build

这将执行构建过程及其相关生命周期。

5. 安装依赖

npm install

这将触发安装相关的生命周期脚本。

预期输出

当运行任何带有生命周期的脚本时,您应该看到类似以下格式的输出:# npm_lifecycle