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

local-package-publisher

v1.0.5

Published

A utility app for publishing your npm packages locally for testing

Downloads

928

Readme

local-package-publisher

A utility app for publishing your npm packages locally for testing, which works !!

npm Package License

About

You have created this awesome npm package and you want to test it locally, before publishing to NPM repository. What are the options you have?

Well, below are some of the possible options, but each of them has some caveat, and as a result, it found out need for this project.

  1. Symbolic Linking :

    At the root directory of your npm package under test, run the command npm link. It would create a symbolic link to the entire folder to the global namespace. So, a folder will be created in the directory where global packages are stored with the name that is same as that of the value of name property in package.json.

    To test/consume this package, at the root of the target project, run npm link [name], where [name] is the value of name property in package.json which is being consumed.

    Cons: Every file in the directory gets linked, which can create problems and can interfere with the build process if the linked package is consumed in another project.

  2. Local NPM Repository :

    You can publish the package under test to a local npm repository hosted using these awesome projects like CNPM,Sinopia, Verdaccio, local-npm etc.

    Cons: You will need to change the registry which npm is pointing to by running npm set registry http://localhost:[port].

    For most of us this might not be a feasible option due to several reasons, but if it does then it is indeed an option worth considering.

  3. Manual Process :

    You can first run npm pack command at the root directory of the project under test. It will generate a tar file with the name [package-name]-[version].tgz.

    Then, unzip the tar file content to a directory, separate from your project.

    Go, to this new directory where the tar contents have been extracted, and run npm link from the directory root. Rest of the steps are same as option 1.

    Cons: The process is a bit cumbersome and involves a lot of steps.

I have found out the third option i.e. Manual Process to be most elegant, even though it requires more steps since it relies on npm pack and it ensures that the content it packs will be same as that of when it will be actually published to NPM repository.

This project is an effort to automate this manual process.

Installation

npm install --save-dev local-package-publisher

To install the package locally to the project

or

npm install -g local-package-publisher

To install the package globally

Usage

Say, you have created a project with the name my-awesome-new-package

To publish this package, go to root directory of the project and run below command:

local-package-publisher -p

or

local-package-publisher --publish

Once you run this command it will give you below success message.

my-awesome-new-package package published successfully to global

This command will publish the package globally. It will also create a directory .local-pack with a setings.json file in it, in your project. Please do not delete it.

You can safely add below line to .gitignore as well.

.local-pack

Thats it !! Now whenever you do any modification in the project and you want to publish the changes, just run the local-package-publisher -p command again.

Now, to consume this published package, just go the root directory of the project where you want to consume it, and run below command. It needs to be done only once.

npm link my-awesome-new-package

Note: No need to run above command again and again.

Once, you are done and you want to remove the published package from global, run below command in the root directory of my-awesome-new-package project:

local-package-publisher -u

or

local-package-publisher --unpublish

Once you run this command it will give you below message.

my-awesome-new-package package has been removed from global

Credit

local-package-publisher wouldn't be possible without using the modules from the following authors:

License

Licensed under MIT

Copyright (c) 2019-2020 Debashish Pal