I Published My First npm Package — Here's Everything I Wish I Knew
Publishing to npm is easy. Doing it RIGHT takes some planning. Here's my complete checklist.
Before You Start
Is It Worth Publishing?
Don't publish if:
It's specific to one project
The name is already taken (obviously)
You're not willing to maintain it
Do publish if:
You've copied this code between 3+ projects
Others would benefit from it
You're willing to fix bugs and accept PRs
Step 1: Project Setup
mkdir my-awesome-package && cd my-awesome-package npm init -y
# Install dev dependencies npm install -D typescript @types/node jest ts-jest
# Create source structure mkdir src tests
Enter fullscreen mode
Exit fullscreen mode
// package.json — the important fields { "name" : "@armorbreak/my-awesome-package" , "version" : "1.0.0" , "description" : "A brief description of what your package does" , "main" : "./dist/index.js" , "types" : "./dist/index.d.ts" , "exports" : { "." : { "import" : "./dist/index.mjs" , "require" :…