Skip to content

santhoshvernekar/sample-npm-package

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

sample-npm-package

This repo demonstrates on how we can create sample npm package and publishing to npm registry

Steps to create new npm package

  • Create the project directory ( mkdir sample-directory )
  • Change into the project directory (cd sample-directory )
  • Initialise a new NPM package ( npm init ) Empty package json will be created
  • Update package.json and project code (index.js)

Steps to push npm package to npm registry

(You should have account created in npm registry if not you can create new account (https://www.npmjs.com/signup)

  • Open command prompt then enter npm login command and provide the login credentials

image

  • run npm whoami to confirm

  • Then run npm publish

image

image

Testing the working of new package

var randomNumberGeneratorSanthoshSamplePackage = require("random-number-generator-santhosh-sample-package")

console.log(randomNumberGeneratorSanthoshSamplePackage(10,5))

  • I created this package to generate the random number and print it on console.

image

To update your package

  • Make changes in your package then run npm version patch command
  • Publish it to npm registry using npm publish command

Happy Coding!!

About

Create simple npm package and publishing to npm registry

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published