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

addition-two-numbers-module

v0.0.0

Published

two numbers addition

Downloads

1

Readme

This repository can be used as a reference guide/sample to enable publishing your first package via npm registry.

:mega: Prerequisites

  • A npmjs account with a verified e-mail address
  • Basic understanding of software package registries (e.g. GitHub Packages, npm)

Steps for Getting started

1. Setup a Project: Setting up a project is required before doing anything.

  • Install Node.js
1. Go to the [Node.js Downloads page](https://nodejs.org/en/download/)
2. Download Node.js for macOS by clicking the "Macintosh Installer" option
3. Run the downloaded Node.js .pkg Installer
4. Run the installer, including accepting the license, selecting the destination, and authenticating for the install.
5. You're finished! To ensure Node.js has been installed, run node -v in your terminal - you should get something like v6.9.4
  • Create an npm account.
https://www.npmjs.com/signup
  • Logging in to the npm account using npm login
➜  sample-npm-publish git:(main) ✗ npm login
npm notice Log in on https://registry.npmjs.org/
Username: nishgupta
Password:
Email: (this IS public) [email protected]
npm notice Please use the one-time password (OTP) from your authenticator application
Enter one-time password: 465775
Logged in as nishgupta on https://registry.npmjs.org/.

2. Initializing a package is required before publishing using npm init

➜  sample-npm-publish git:(main) ✗ npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.

See `npm help init` for definitive documentation on these fields
and exactly what they do.

Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
package name: (sample-npm-publish) sample-npm-publish
version: (1.0.0) 0.0.0
description: sample package to demonstrate npm publish
entry point: (index.js)
test command:
git repository: (https://github.com/nishantms/sample-npm-publish)
keywords: publish
author: nishant gupta
license: (ISC)
About to write to /Users/nishantms/sample-npm-publish/package.json:

{
  "name": "sample-npm-publish",
  "version": "0.0.0",
  "description": "sample package to demonstrate npm publish",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/nishantms/sample-npm-publish.git"
  },
  "keywords": [
    "publish"
  ],
  "author": "nishant gupta",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/nishantms/sample-npm-publish/issues"
  },
  "homepage": "https://github.com/nishantms/sample-npm-publish#readme"
}


Is this OK? (yes) yes

### 3. Building a package is required before publishing

Lets first implement a simple function that add two numbers in the npm module. This function looks like below:

File Name: index.js

const addFns = {
  add : function addTwoNums( num1, num2 ) {
    return (num1 + num2) ;
  }
}
  
module.exports = addFns

4. Publishing a package is required before publishing using npm publish

To check if your package name is usable or not, go to the command-line and type npm search addition-two-numbers-module

➜  sample-npm-publish git:(main) ✗ npm search addition-two-numbers-module
No matches found for "addition-two-numbers-module"

Now after checking the name availability, go to command-line/terminal and type npm publish

➜  sample-npm-publish git:(main) ✗ npm publish
npm notice
npm notice 📦  [email protected]
npm notice === Tarball Contents ===
npm notice 4.2kB   README.md
npm notice 167.9kB images/signup.png
npm notice 132B    index.js
npm notice 568B    package.json
npm notice === Tarball Details ===
npm notice name:          addition-module
npm notice version:       0.0.0
npm notice filename:      addition-module-0.0.0.tgz
npm notice package size:  115.6 kB
npm notice unpacked size: 172.8 kB
npm notice shasum:        edbfce0c054de6e4c056a243f9ea02c7cd7d1a85
npm notice integrity:     sha512-GhFATM08xEqbC[...]YoVPDPtMpPR0w==
npm notice total files:   4
npm notice
npm notice Publishing to https://registry.npmjs.org/
npm notice Open https://www.npmjs.com/login/7ab7f458-7ebb-47bd-acb9-e50f868b8ea9 to use your security key for authentication or enter OTP from your authenticator app
This operation requires a one-time password.
Enter OTP: 0939932908353002

:books: Resources