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

hip-special-cli

v1.0.23

Published

a hippus build cli

Downloads

27

Readme

简介

npm是javascript的包管理工具,是前端模块化下的一个标志性产物

简单地地说,就是通过npm下载模块,复用已有的代码,提高工作效率

npm账号创建,登录,发布

发布npm包需要登录npm账户,输入账户,密码,邮箱,然后在项目目录下执行发布命令就行

npm adduser

npm publish

脚手架npm包发布

创建一个基于ts的脚手架

npm init -y

添加typeScript依赖

执行: npm install typescript, 添加typeScript的依赖包到npm包中

配置tsconfig.json

创建一个tsconfig.json文件,并添加一些配置

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "lib": ["es2017"],
    "declaration": true,
    "outDir": "./",
    "rootDir": "./src",
    "strict": true,
    "skipLibCheck": true,
    "sourceMap": false,
  },
  "include": ["./src"],
  "exclude": ["node_modules","./src/modules"]
}

创建目录结构

bin目录存放的是node执行文件的入口,command目录存放的是现实的命令,typings存放的是全局类型声明文件,tools存放的是编译工具,test目录存放测试样例,lib存放自定义工具函数等等

配置package.json

  1. 修改npm包入口
  2. 配置npm包的typescript声明文件

image-20210607185749750

  1. 配置可执行文件的位置
{
  "bin": {
      "hip-cli": "bin/index.js"
   },
}

上面代码指定,hip-cli 命令对应的可执行文件为 bin 子目录下的 index.js。Npm会寻找这个文件,在node_modules/.bin/目录下建立符号链接。在上面的例子中,index.js会建立符号链接npm_modules/.bin/index。由于node_modules/.bin/目录会在运行时加入系统的PATH变量,因此在运行npm时,就可以不带路径,直接通过命令来调用这些脚本。

npm包发布

npm包的发布基本和脚手架npm包差不多,区别在于不需要配置bin。

一些常用的npm命令

# npm link用来在本地项目和本地npm模块之间建立连接,可以在本地进行模块测试
npm link

npm publish # 发布当前包

npm unpublish 包名 --force # 删除整个包


# 升级patch package.json 中的版本号2.0.0-0变为 2.0.0;
# package.json 中的版本号2.0.0变为 2.0.1;
npm version patch 

# 升级minor
# package.json 中的版本号2.0.1变为 2.1.0;
npm version minor

# 升级major
# package.json  中的版本号3.1.0变为4.0.0
npm version major