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

fjj-test01

v1.2.2

Published

写代码,然后配置package.json bin,main 然后 npm login npm publish

Downloads

281

Readme

脚手架流程

写代码,然后配置package.json bin,main 然后 npm login npm publish

分析

ok后测试一下这个 npm i fjj-test01 -g

fjj-test01

直接执行了打印

来分析一下这个包 where fjj-test01

找到了那个cmd,发现直接使用了node环境去执行 \node_modules\fjj-test01\bin\index.js 即bin中配置的文件

这样第一个脚手架就执行完毕啦

如何进行本地调试呢,不用每次都要重新提交,下载?

可以在本地包目录 npm link 会在本地创建符号链接 然后执行命令就是最新的代码

npm unlink 就是取消

符号链接的是全局node_module中的包的文件夹 在node_module文件夹下使用 dir /aL 可以查看当前目录下的符号链接,发现他指向我们代码本地

当存在分包情况时,如何本地链接呢?

新建一个02,02是本地的,我们01要使用02,可以通过

在02中 npm link 在全局node_module创建符号链接

在01中 npm link lib-02 将全局node_module的对应的02链接过来

由于不是远程下载,我们需要自己手动加入package.json 02的依赖 注意:如果每加上线后就会找不到这个依赖啦

在01中就可以正常使用02啦

本地链接了如何取消呢?

01中取消库引用链接 npm unlink lib-02

02中取消链接 npm unlink

注意: 在项目目录中使用:解除项目与全局符号链接的关联,但不会删除全局符号链接。 在全局环境中使用:删除全局 node_modules 中的符号链接。

全局取消 npm unlink -g 包名 可以在全局node_module查看包名

如何注册脚手架命令和解析参数呢?

require('process').argv 就能拿到参数 解析参数比较复杂,我们一般通过框架去实现

发布流程

发布前需要解除 符号链接

我们需要先把lib-02给发布 npm publish 注意版本迭代需要更新版本号

这里发现这个名字太常见了,所以我们改名@fangxh/lib-02 发现npm 默认将以 @scope 命名的包视为私有包,而私有包需要进行付费订阅 改名fangxh-lib-02

然后发布01,改一下他的依赖,和版本

重新下载 npm i -g fjj-test01 发现存在一定的延时