April 20, 2023

Publish NPM and PyPI Packages

This post is also for myself - I often want to register packages to https://www.npmjs.com/ and/or https://pypi.org/ and keep on looking for instructions that I forget. Please refer to the two great tutorials in the references section for details. I only list the key steps and notes that I often need to refer to below.

Setup Github Repo for the Package

The easiest way to start is to find an example repo and revise the package information:

Package and Publish

You need to register accounts on https://www.npmjs.com/ and https://pypi.org/.

For NPM:

npm install
npm login
npm publish

Then, you should see your published package, e.g., https://www.npmjs.com/package/harry-greeter

For PyPI:

Find classifier (such as supported licenses) from https://pypi.org/classifiers/ for setup.py, then:

python setup.py sdist
twine upload dist/*

Then, you should see your published package, e.g., https://pypi.org/project/harrywang-greeter/

References

PS. The featured image for this post is generated using Stable Diffusion, whose full parameters with model link can be found at Takin.AI.