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 🙏

© 2025 – Pkg Stats / Ryan Hefner

transbranch

v0.1.1

Published

```shell $ mkdir transbranch # 创建transbranch文件夹 $ cd transbranch && mkdir bin $ npm init # 初始化 `package.json` 文件 ```

Readme

首先创建文件夹,初始化package.json文件,在该文件夹下创建bin目录:

$ mkdir transbranch   # 创建transbranch文件夹
$ cd transbranch && mkdir bin
$ npm init     # 初始化 `package.json` 文件

cd到bin目录下,新建tool.js文件,编写如下代码,在js文件顶部加上#!/usr/bin/env node这段代码:

var fs = require("fs"),
    path = require('path');

var run = function (obj){
    if(obj[0] === '-v'){
        console.log('version is 1.0.0');
    } else if (obj[0] === '-h') {
        console.log('Useage:');
    } else {
        fs.readdir(path, function(err,files){
            if(err){
                return console.log(err);
            }
            for(var i = 0; i< files.length; i+=1){
                console.log(files[i]);
            }
        });
    }
}

run(process.argv.slice(2));

还需要一个package.json文件

{
    "name": 'transbranch',
    "version": "0.1.0",
    "description": "",
    "main": "tool.js",
    "bin": {
        "transbranch": "bin/tool.js"
    },
    "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "tool": "node bin/tool.js"
    },
    "author": "sherry",
    "license": "ISC",
}

运行 node bin/tool.js 会显示当前文件夹下的所有文件和文件夹名

package.json文件中的bin里面的内容表示这个字段讲transbranch命令映射到了你的 bin/tool.js 脚本。

目录输入npm link 会自动添加全局的 symbolic link ,然后就可以使用自己的命令了。

如果已经 npm link 了一遍,再link一遍会报错,即使npm unlink也会报错 删除目录运行 rm -rf /usr/local/bin/transbranch

发布到npm

npm login 先登录npm,依次输入用户名、密码、邮箱 查看是否登录可以用 npm whoami 查看 npm publish 然后发布 如果现在是在淘宝镜像的npm,则用 npm login --registry http://registry.npmjs.org npm publish --registry http://registry.npmjs.org

1、本地更新版本号 比如我想来个1.0.1版本,注意,是最后一位修改了增1,那么命令 :npm version patch 回车就可以了; 比如我想来个1.1.0版本,注意,是第二位修改了增1,那么命令 :npm version minor 回车就可以了; 比如我想来个2.0.0版本,注意,是第一位修改了增1,那么命令 :npm version major 回车就可以了; 2、修改远端的版本,提交到远端npm中: npm publish