Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Publishing a TypeScript Library | TypeScript Mastery lesson | BraveProgrammer
  1. Courses
  2. /
  3. TypeScript Mastery

Lesson 44 of 56

·Typescript

Publishing a TypeScript Library to npm

20 minutes

Course progress79%

Prepare package.json

{
  "name": "my-lib",
  "version": "1.0.0",
  "main": 
   
   
   
      

"dist/index.cjs.js"
,
"module"
:
"dist/index.esm.js"
,
"types"
:
"dist/index.d.ts"
,
"files"
:
[
"dist"
]
,
"scripts"
:
{
"build"
:
"tsc && rollup -c"
}
}

Build steps

  1. Compile with tsc to generate declarations.
  2. Bundle with Rollup/Webpack for a ready‑to‑publish bundle.

Publishing

npm login
npm publish

Using publishConfig

"publishConfig": { "access": "public" }

Semantic Release (optional)

Automate version bump & changelog with semantic-release.

Info

Never publish source maps unless you want to expose source code.
Make it stickPractice what you've learned1 quiz · 3 practical tests · Optional activities from TypeScript MasteryBrowse activities
Previous lessonMonorepos – Lerna, Yarn Workspaces, and NxContinue to lesson 45Advanced Generics – Variadic Tuple TypesBack to TypeScript Mastery curriculum