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

work_node_shanjiangwei2

v1.0.3

Published

...

Downloads

4

Readme

什么是 npm?

  • npm 是 nodeJS 的包管理器。
  • 我们可以在 npm 中发布自己的包,也可以去下载第三方包使用。

nmp 初始化包

npm init 一步一步设置初始化 npm init -y 直接生成初始化 初始化后会生成一个 package.json 文件,这个文件就是对包的描述

{ "name": "demo-npm",包名 注意:文件名字越长越好,避免和其他人的包冲突 "version": "1.0.0",版本 例如:1.1.3 "description": "", 描述 例如:包的作用 "main": "index.js",入口文件 注意路径可以更改 "scripts": {脚本 "test": "echo "Error: no test specified" && exit 1" }, "keywords": [],关键字 "author": "",作者 "license": "ISC"协议许可 }

发包

  • 开始发包:
  • 1.官网注册 npm 账号
  • 2.激活邮箱
  • 3.编写包内容
  • 4.登陆 (npm login)
  • 5.npm publish 上传包
  • 6.README.md 记录包

注意:上传包的时候一定要把源切换到 npm 上

更新包

1.更改 package.json 文件中的版本,然后 npm publish

nrm 切换源

为什么要切换源:npm 是国外仓库的网址,网络不好的情况下容易丢包或者下载很慢, 建议更换为国内的仓库地址--淘宝源

  • 安装 npm i nrm -g

  • 1.nrm ls 查看所有的源 ---》

  • 2.nrm use (例如:npm) 切换源到 npm

  • 3.nrm add 名字 地址 添加源

  • 4.nrm del 名字 删除源

  • npm config set registry https://registry.npm.taobao.org 配置淘宝镜像

  • npm config set cache '路径' 设置全局缓存地址

  • npm config set prefix '路径' 设置全局下载地址

  • npm config ls 查看配置列表

  • npm root -g 查看下载的根路径

下载包

  • 本地下载 会在当前文件目录下生成一个 node_modules 文件,存放的就是第三方下载的包

  • 1.npm install <包名> --save-dev npm i <包名> -D 下载在开发环境中 会在 package.json 文件中添加一个字符安 devDependencies 包含插件名和版本号

  • 2.npm install <包名> --save npm i <包名> -S 下载在生产环境中 会在 package.json 文件中添加一个字符安 dependencies 包含插件名和版本号

  • 3.全局下载 npm install <包名> --global npm i <包名> -g