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

basic_05_publish

v2.0.1

Published

-------------------------- publish --------------------------

Downloads

9

Readme

the example is based on the following tutorial

https://medium.freecodecamp.org/how-to-create-and-publish-your-npm-package-node-module-in-just-10-minutes-b8ca3a100050


publish

$ npm init -y

by default, the package name is the same as directory name

change package name to basic_05_publish

create index.js as below

module.exports = (message) => message.toUpperCase();

$ npm login $ npm publish

go to https://www.npmjs.com/settings/jyang49/packages to see my packages

view the package detail

notice that the version is 1.0.0 which was set when running "npm init"

$ npm view basic_05_publish (or, npm view basic_05_publish --json) ... dist-tags: latest: 1.0.0


install and use package

from another directory

$ npm i basic_05_publish

create following app.js (or copy app.js)

const uppercaser = require('basic_05_publish');

console.log(uppercaser('hello world!'));

run app.js

$ node app.js


update package

make code change to index.js

module.exports = (message) => 'v1: ' + message.toUpperCase();

update version in package.json

this is required, because cannot publish package with the same version again

"version": "1.1.0",

pubish

npm publish

now the latest tag is associated with the version 1.1.0

if run npm install, will install version 1.1.0


delete package

npm unpublish [email protected]


update package with tag

update version in package.json

notice that even 1.1.0 was unpublished, still cannot use this version, which is by design for security reason

"version": "1.1.1",

$ npm publish --tag bugfix1

show tags

$ npm show basic_05_publish ... dist-tags: bugfix1: 1.1.1 latest: 1.0.0


managing tag

show tags

$ npm dist-tag ls basic_05_publish bugfix1: 1.1.1 latest: 1.0.0

remove tag

$ npm dist-tag rm basic_05_publish bugfix1

show tags again, now the tag bugfix1 was gone

$ npm dist-tag ls basic_05_publish latest: 1.0.0

add tag

$ npm dist-tag add [email protected] bugfix11

add another tag

$ npm dist-tag add [email protected] feature11

show tags. Notice that two tags associated with the same version

$ npm dist-tag ls basic_05_publish bugfix11: 1.1.1 feature11: 1.1.1 latest: 1.0.0


install package by tag

When specify specific tag, will ignore settings in package.json and package-lock.json

$ npm i basic_05_publish@feature11

$ npm i basic_05_publish@latest