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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@linschin/demo-npm-library

v1.0.4

Published

Demonstration npm library package

Readme

demo-npm-library

Demonstration of a simple npm library. A reminder on how to create and use an npm library locally.

References:

Project generated by project-scaffolder-ts

Table of Contents

Installation

cd demo-npm-library
npm install
npm run ci

Local Development of an npm Library

When developing an npm library, you may want to test it locally before publishing it to the npm registry. This can be done by linking the library to a local project or by packing the library into a tarball and installing it in the project.

There are multiple methods to use an npm library locally.

  1. npm link
  2. npm pack

npm link

With this method, we create a symbolic link to the library package in the global node_modules folder, and then link it to the project folder's node_modules.

For more information about the npm link command, see npm help link.

npm-link - Symlink a package folder

This is handy for installing your own stuff, so that you can work on it and test iteratively without having to continually rebuild.

Package linking is a two-step process.

First, npm link in a package folder with no arguments will create a symlink in the global folder {prefix}/lib/node_modules/ that links to the package where the npm link command was executed. It will also link any bins in the package to {prefix}/bin/{name}. Note that npm link uses the global prefix (see npm prefix -g for its value).

Next, in some other location, npm link package-name will create a symbolic link from globally-installed package-name to node_modules/ of the current folder.

Note that package-name is taken from package.json, not from the directory name.

The package name can be optionally prefixed with a scope. See npm help scope. The scope must be preceded by an @-symbol and followed by a slash.

1. Link the library package to the global node_module folder

cd demo-npm-library
npm link

2. Add the library package to your project folder

cd <project-folder>
npm link demo-npm-library

Note: To link multiple local libraries, execute npm link in a single command

npm link demo-npm-library another-library

3. Use the library in the project

// index.ts
import { add, subtract } from 'demo-npm-library'
import { greet, farewell } from 'demo-npm-library'

console.log(add(1, 3))
console.log(subtract(5, 2))

console.log(greet('Linus'))
console.log(farewell('Linus'))

4. Clean up

# Remove linked library from the project
cd <project-folder>
npm unlink

# Remove linked library from the global node_module folder
npm ls --global
npm uninstall demo-npm-library

npm pack

With this method, we create a tarball of the library package and install it in the project folder.

For more information about the npm pack command, see npm help pack.

1. Create a tarball of the library package

Note: A pre-prepared script localpack is provided in the package.json file to create the tarball that is created in the dist folder.

cd demo-npm-library
npm run localpack

2. Install the tarball in the project folder

cd <project-folder>
npm install ../demo-npm-library/dist/demo-npm-library-1.0.0.tgz

3. Use the library in the project

// index.ts
import { add, subtract } from 'demo-npm-library'
import { greet, farewell } from 'demo-npm-library'

console.log(add(1, 3))
console.log(subtract(5, 2))

console.log(greet('Linus'))
console.log(farewell('Linus'))

4. Clean up

# Remove the installed package from the project
cd <project-folder>
npm uninstall demo-npm-library

There is no need to clean up the library folder since the tarball is created in the dist folder and does not affect the library package itself.

Testing

The library is tested using vitest. Test executed has been automatically baked into the npm run ci command.

There are two npm scripts provided for testing:

  1. npm run test: Executes the tests (warning - build must be executed separately)
  2. npm run dev: Starts the test runner in watch mode

Publishing

Publishing utilises the changesets npm library to manage versioning and changelogs. There is no automated publishing proceess through GitHub Actions.

In order to publish the library to the npm registry, you need to:

  1. Create a changeset: This will create a new version of the library and update the changelog.
    # Starts an interactive prompt to determine the version bump type (major, minor, patch) 
    npx changeset
  2. Create a changeset version and publish the library to the npm registry:
    npm run local-release
  3. Commit the changeset files to your repository.

Pre-requisites

Ensure that you have a valid npm account and that you are logged in to the npm registry. You can log in using the following command:

npm login