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

npmdemo001

v1.0.5

Published

demo

Downloads

8

Readme

1.创建package.json文件

cmd>npm init

按照提示输入package名,description,email,版本等信息,就会自动生成

{
  "name": "npmdemo001",
  "version": "1.0.3",
  "description": "demo",
  "main": "./lib/module.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/ccq18/npmdemo.git"
  },
  "keywords": [
    "demo"
  ],
  "author": "ccq18",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/ccq18/npmdemo/issues"
  },
  "homepage": "https://github.com/ccq18/npmdemo#readme"
}

2.编写你的module

创建lib目录,创建module.js文件,内容:

var A = "value A";
var B = "value B";
exports.values = function() {
return { A: A, B: B };
}

3.添加用户

cmd>npm adduser

按照提示输入用户名,密码和邮箱

4.发布

cmd>npm publish

如果不带参数,会查找当前目录下的package.json文件,按照该文件描述信息发布module

如果指定目录,就在这个目录下查找package.json文件

Ps: 1.包名不能喝目前已有的包冲突
2.记得去网站上验证邮箱 3.记得添加.gitignore

/node_modules
/.idea
.DS_Store

4.注意package.json的main 是默认执行的文件名

5.验证

在http://search.npmjs.org/可以查询刚刚发布的module

6.下载使用

cmd>yarn add npmdemo001

可以看到在node_modules目录下载了yypi模块

在node.exe目录新建test.js文件:

var util = require('util');
var A = "a different value A";
var B = "a different value B";
//var m1 = require('npmdemo001/lib/module'); var m1 = require('npmdemo001');

util.log('A='+A+' B='+B+' values='+util.inspect(m1.values()));

cmd>node test.js

得到输出:

30 Dec 23:48:44 - A=a different value A B=a different value B values={ A: 'value

A', B: 'value B' }

7.多版本发布

修改package.json里的版本号,重新npm publish即可

8.取消发布

cmd>npm unpublish