Create Your First NPM package using Angular
Google

Create Your First NPM package using Angular

NPM:- ( Node Package Manager). NPM is the package manager for the Node JavaScript platform.?It puts modules in place so that Node can find them, and manages dependency conflicts. It is used to publish, discover, install, and develop node programs.

How to create Node Package Using Angular

?1) Make sure you have an NPM account if not check it out here https://www.npmjs.com/

?2) First we have to create an angular project using the command ng g new project_name?

?3) Then we have to create an angular library for which we have to create package in this example I have created a simple button package. We have to use create library command?ng g library button

?4) After creating the library we can see another project folder created in our project directory which is having its own angular configuration.

?5) We can verify in our main package.json file which contains project object which has 2 projects now first our main project with type application and?second is our button project which is having type library.

?6) Before publishing our first package we have to create a build of button library using?

?ng build package_name i.e ng build button command.

?7) You have to log in with your NPM credentials using the npm login command. After entering this command you have to add your username password and register your email id.?Then you will receive an OTP over your mail.

?8) After successful login you have navigated to your library build folder and then publish your package using npm publish.

?How to Use Node package

Simply go on npm.js and search package name simple add dependency in your project using npm install package_name.

?Few things that might be blockers for you.

?The package name must be unique if the package already exists you have to choose another name. Or else you can add your username before the package name in the package.json file of your library. Then you can create a build and instead of the npm publish command you have to add one more parameter like npm publish --access=public

?beacause when you add your username before the package name NPM will consider that package is a private package by default and private packages are paid in NPM.

?How to update the NPM package version.

?Simply update your code. Then update the version in package.json. Login using the npm login command then publish your updated version using the npm publish command

Sample Github code click here

Nitish Garg

Student at B K Birla Institute of Engineering & Technology, Pilani

1 年

hey please check this query on stackoverflow , any guidance or help will be appreciated, Thank you in advance. https://stackoverflow.com/questions/77152634/create-an-npm-package-for-react-native-with-swift-libraries

回复
Vaibhav Gawas

Sr. Software engineer at IGT Solutions

2 年

Most imformative??

要查看或添加评论,请登录

Harshal S.的更多文章

  • Unit Testing In Angular

    Unit Testing In Angular

    What & Why Unit Testing? Unit testing your #Angular application helps you check that your application is working as you…

  • Micro Frontend With Angular & React Using Module Federation

    Micro Frontend With Angular & React Using Module Federation

    I have already explained how micro frontend work please check out this link if you are aware of it (Micro Frontend)…

    9 条评论
  • Micro Frontend with Module Federation

    Micro Frontend with Module Federation

    I have already explained how micro frontend work please check out this link if you are aware of it (Micro Frontend) Now…

    10 条评论
  • Storybook With Angular

    Storybook With Angular

    Have you heard about the Storybook? Let me explain what is Storybook. A storybook is a tool for UI development.

  • The simple explanation of Microfrontend

    The simple explanation of Microfrontend

    Modern web apps are more complicated, and some of them are managed by multiple teams. When you want to put one of the…

    11 条评论
  • Send emails using Node.js, Nodemailer, and Angular and verify user account

    Send emails using Node.js, Nodemailer, and Angular and verify user account

    This code sends a simple HTML email using the free SMTP testing service and after getting the verification mail user…

    3 条评论

社区洞察

其他会员也浏览了