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

npm-hello-world-demo

v1.0.2

Published

a sample tutorial that step to step publish npm pageage.

Downloads

4

Readme

npm publish 操作步骤

  • 编写模块

1)新建文件夹,比如:npm-hello-world-demo

  1. 该文件夹下新建js文件,比如:index.js

  js内容如下:

  exports.sayHello=function(){     return "Hello world!";   };

  • 初始化包描述文件

使用cmd命令定位到npm-hello-world-demo文件夹

输入 npm init 并执行

npm的init命令可以帮助你生成package.json文件,这是我的文件内容:

{
	"name": "your_package_name",
	"version": "1.0.0",
	"description": "'something...'",
	"main": "index.js",
	"scripts": {
		"test": "echo \"Error: no test specified\" && exit 1"
	},
	"keywords": [
		"Hello",
		"world"
	],
	"author": "Your Name",
	"license": "MIT"
}
  • 注册包仓库账号
npm adduser

输入这个命令会有提示输入用户名,密码,邮箱等资料

这和去官方源仓库https://www.npmjs.com/注册是一样的

  • 上传包
npm publish

如果上传成功会提示

[email protected]

否则上传失败

这个时候去https://www.npmjs.com/登陆仓库账号就可以看到自己的包啦

  • 安装包

npm install npm-hello-world-demo

通过此命令可以在世界上任一一台机器上安装npm-hello-world-demo了

发布包过程可能会遇到很多问题,我印象比较深刻的是npm ERR publish 403

You do not have permission to publish 'npm-hello-world-demo'.Are you logged in as

the corrent user?:npm-hello-world-demo

意思是我没权限发布somepackage,并问我是否使用了正确的账号,

那也许是npm-hello-world-demo被别人发布过了吧,所以我修改了package.json文件

把name改成npm-hello-world-demo1.

  • 分析包

这个命令可以为你分析出当前路径下能够通过模块路径找到的所有包,并生成依赖树。

npm ls