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

ai-install

v1.1.1

Published

Say goodbye to `npm install`, no need `npm install`, throw away `npm install`.

Readme

ai-install 命令

永别了 npm install, 让你的前端项目免执行 npm install.

例子

在你的前端项目中,

1)添加 npx -y ai-install(npm>=7) 到 package.json->scripts->start/build.

使用npx -y ai-install(npm<=6)

{
  "name": "ai-install-demo",
  "scripts": {
    "start": "npx -y ai-install && xxx serve --open",
    "build": "npx -y ai-install && xxx build"
  },
  "devDependencies": {
    "xxx": "x.y.z"
  }
}

2)新增 npm-start.sh 文件,内容是:

npm start

那么 git clone 拉取代码之后, 双击 npm-start.sh 运行,免敲命令。

原理

package.json->scripts 中的

npx -y ai-install

执行 ai-install 命令:如果项目未初始安装,那么自动执行 npm install.

npx 优先执行本地命令,如果本地不存在则去 npmjs.com 查找。

思考

它节省的是敲击 npm i 的一秒钟么?不是!

因为 npm i 安装结束后,并没能无缝衔接 npm start,浪费了10秒~60秒。

如果使用 npx -y ai-install,那么 npm start 很可能提前一分钟启动。

yarn & pnpm

npx -y ai-install

如果 yarn 项目未初始安装,会自动执行 yarn install

如果 pnpm 项目未初始安装,会自动执行 pnpm install

源代码

package.json 定义了一个 'ai-install' 的命令。

{
  "name": "ai-install",
  "version": "1.0.0",
  "description": "Say goodbay to `npm install`, no need `npm install`, throw away `npm install`.",
  "main": "index.js",
  "bin": {
    "ai-install": "index.js"
  }
}

index.js 如果项目未初始化安装,那么区分 npm/yarn/pnpm 环境,执行对应的 npm install 命令。

#!/usr/bin/env node

var fs = require('fs');
var child_process = require('child_process');

if (!fs.existsSync('node_modules')) {
  if(fs.existsSync('yarn.lock')){
    child_process.execSync('yarn install', { stdio: 'inherit' });
  } else if (fs.existsSync('pnpm-lock.yaml')){
    child_process.execSync('pnpm install', { stdio: 'inherit' });
  } else if (fs.existsSync('package-lock.json') || fs.existsSync('npm-shrinkwrap.json')){
    // 'npm ci' is faster than 'npm i'.
    child_process.execSync('npm ci', { stdio: 'inherit' });
  } else {
    child_process.execSync('npm i', { stdio: 'inherit' });
  }
}