1.0.4 • Published 3 years ago
random-number-generator-santhosh-sample-package v1.0.4
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
run npm whoami to confirm
Then run npm publish
- Your new package will be published to your npm registry like mine :)
Testing the working of new package
- Open NPM RunKit (https://npm.runkit.com/random-number-generator-santhosh-sample-package)
- Invoke the method we created using below piece of code and click on run button
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.
Happy Coding!!