This is the easiest and fastest way I know to create and publish a package to NPM. In this video we will publish a simple react component to NPM using tsdx, typescript and storybook.

We will also see how versions work and how to use “npm version”.

At the end of the video we will consume our new published package from a new create-react-app project using typescript.


Published package: https://www.npmjs.com/package/@bmvantunes/youtube-demo
All my packages: https://www.npmjs.com/~bmvantunes

Timeline

  • 00:00 Introduction
  • 00:15 Example: why you may need to publish packages
  • 01:00 Show tsdx documentation
  • 01:48 Check package name and Create npm account
  • 02:18 npm login
  • 02:26 Create our component library using tsdx
  • 04:40 Change name to scoped package
  • 05:00 npm publish and npm publish --access public
  • 06:12 See published package on npmjs.com
  • 06:43 npm version - change the version of your package
  • 09:15 Add a new component
  • 10:38 Named exports vs Default exports
  • 12:03 Is it possible to automate all this?
  • 12:45 Consume our package in a new create-react-app project

#npm #node

Create and Publish Packages to NPM Made Easy - Using tsdx
7.15 GEEK