SlideShare a Scribd company logo
Introduction to
Introduction
to
By Suroor Wijdan
Introduction to
Agenda
● What is NPM?
● Understanding package.json
● Where to find Packages?
● Installing Packages
● Writing your own Packages
● Command Line
● Publishing to NPM
● Questions & Exercises
Introduction to
What is NPM?
First Time Using NPM
Introduction to
What is NPM?
● A Node Package Manager
● No other Package Manager comes closer
● Is also used by developers who don’t use Node.js at all
● Created by Isaac Z. Schlueter
● Breeze to use
● Recently made into a company, NPM Inc. by Isaac
● Free and Open Source!
Introduction to
Understanding package.json
● It is a valid JSON object
● name and version fields are required, the combination
makes a unique identifier for the package
● Some used fields in package.json
○ description
○ keywords
○ homepage
○ bugs
○ license
○ author & contributors
○ main
○ bin
○ dependencies
○ scripts - {start, preinstall}
Introduction to
Where to find Packages?
https://npmjs.org
Introduction to
Installing Packages
● npm comes along with node.js
● to install a package run:
○ npm install <package-name>
○ npm install <tarball file>
○ npm install <tarball url>
● install a package globally
○ npm install -g <package-name>
Note: Global installation makes the package available globally irrespective of the directory you installed it from.
Introduction to
Writing your own packages
● Install Grunt , the javascript task runner
○ npm install -g grunt-cli
● Run command :
○ grunt-init node
● Answer few questions and you are ready with a nice
package.json file and main .js file for your package.
Introduction to
Writing your own packages
The generated folder structure should look something like this:
Write the code in the .js file created, you can also create many more files as
per your need.
Introduction to
Writing your own packages
Some guidelines to keep in mind when writing new
packages:
● Don’t reinvent the wheel
● Try to contribute to other packages whenever possible
● If you are writing a utility package, then multiple exports should be used
● If your package needs to maintain a state then its good to export a
constructor
● Most Important thing, KEEP IT COOL!
Introduction to
Command Line
To be able to use your package through command line, you need to specify
‘bin’ in package.json as follows:
"bin": {
"nodeart": "lib/nodeArt.js"
}
Also add this #! /usr/bin/env node at the top of “lib/nodeArt.js” file. This tells how the file should be
executed.
As above, ‘nodeart’ will be the command available to you when you install
the package on your machine.
Introduction to
Command Line
You can receive the arguments passed from command line in process.argv
array. First two values in the array are pre-defined :
[ 'node', '/opt/node-v0.10.5-linux-x64/bin/nodeArt']
The actual arguments being passed will be available at indexes greater than
1. So if you run nodeart ‘suroor wijdan’, the process.argv array will be:
[ 'node', '/opt/node-v0.10.5-linux-x64/bin/nodeArt', ‘suroor wijdan’]
Introduction to
Command Line
So its better to slice the array and store the arguments in another variable:
var argumentsPassed = process.argv.slice(2);
Introduction to
Publishing to NPM
To publish on NPM, you just need to have an account on it. To make an
account run the following command:
Once you have the account ready, just run the below command from project
root to publish your module:
And thats all, everything else will be taken care of by NPM registry.
npm adduser //will ask for username, email and password
npm publish
Introduction to
Questions?
Introduction to
/THANKS/ig
Introduction to
References
1. NPM Logo - https://npmjs.org
2. https://npmjs.org/doc/
3. Image Credit - http://nodejsreactions.tumblr.com/post/64781824365/first-time-using-npm
4. Grunt Logo - http://gruntjs.com

More Related Content

What's hot

A Introduction of Packer
A Introduction of PackerA Introduction of Packer
A Introduction of Packer
Freyr Lin
 
Nodejs vatsal shah
Nodejs vatsal shahNodejs vatsal shah
Nodejs vatsal shah
Vatsal N Shah
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
Dinesh U
 
Node JS Crash Course
Node JS Crash CourseNode JS Crash Course
Node JS Crash Course
Haim Michael
 
Docker and WASM
Docker and WASMDocker and WASM
Docker and WASM
Antonis Kalipetis
 
Understanding react hooks
Understanding react hooksUnderstanding react hooks
Understanding react hooks
Samundra khatri
 
Ceph RBD Update - June 2021
Ceph RBD Update - June 2021Ceph RBD Update - June 2021
Ceph RBD Update - June 2021
Ceph Community
 
Nodejs presentation
Nodejs presentationNodejs presentation
Nodejs presentation
Arvind Devaraj
 
Embedded Android Workshop with Oreo
Embedded Android Workshop with OreoEmbedded Android Workshop with Oreo
Embedded Android Workshop with Oreo
Opersys inc.
 
BlueStore: a new, faster storage backend for Ceph
BlueStore: a new, faster storage backend for CephBlueStore: a new, faster storage backend for Ceph
BlueStore: a new, faster storage backend for Ceph
Sage Weil
 
librados
libradoslibrados
librados
Patrick McGarry
 
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...Opersys inc.
 
오픈소스의 이해와 활용
오픈소스의 이해와 활용오픈소스의 이해와 활용
오픈소스의 이해와 활용
SANGHEE SHIN
 
Typescript in React: HOW & WHY?
Typescript in React: HOW & WHY?Typescript in React: HOW & WHY?
Typescript in React: HOW & WHY?
Saulius Skeirys
 
Practical Windows Kernel Exploitation
Practical Windows Kernel ExploitationPractical Windows Kernel Exploitation
Practical Windows Kernel Exploitation
zeroSteiner
 
Rust vs C++
Rust vs C++Rust vs C++
Rust vs C++
corehard_by
 
Redux workshop
Redux workshopRedux workshop
Redux workshop
Imran Sayed
 
AndroidとSELinux
AndroidとSELinuxAndroidとSELinux
AndroidとSELinux
android sola
 
Bluestore
BluestoreBluestore
Bluestore
Patrick McGarry
 
Node js
Node jsNode js

What's hot (20)

A Introduction of Packer
A Introduction of PackerA Introduction of Packer
A Introduction of Packer
 
Nodejs vatsal shah
Nodejs vatsal shahNodejs vatsal shah
Nodejs vatsal shah
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
 
Node JS Crash Course
Node JS Crash CourseNode JS Crash Course
Node JS Crash Course
 
Docker and WASM
Docker and WASMDocker and WASM
Docker and WASM
 
Understanding react hooks
Understanding react hooksUnderstanding react hooks
Understanding react hooks
 
Ceph RBD Update - June 2021
Ceph RBD Update - June 2021Ceph RBD Update - June 2021
Ceph RBD Update - June 2021
 
Nodejs presentation
Nodejs presentationNodejs presentation
Nodejs presentation
 
Embedded Android Workshop with Oreo
Embedded Android Workshop with OreoEmbedded Android Workshop with Oreo
Embedded Android Workshop with Oreo
 
BlueStore: a new, faster storage backend for Ceph
BlueStore: a new, faster storage backend for CephBlueStore: a new, faster storage backend for Ceph
BlueStore: a new, faster storage backend for Ceph
 
librados
libradoslibrados
librados
 
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
 
오픈소스의 이해와 활용
오픈소스의 이해와 활용오픈소스의 이해와 활용
오픈소스의 이해와 활용
 
Typescript in React: HOW & WHY?
Typescript in React: HOW & WHY?Typescript in React: HOW & WHY?
Typescript in React: HOW & WHY?
 
Practical Windows Kernel Exploitation
Practical Windows Kernel ExploitationPractical Windows Kernel Exploitation
Practical Windows Kernel Exploitation
 
Rust vs C++
Rust vs C++Rust vs C++
Rust vs C++
 
Redux workshop
Redux workshopRedux workshop
Redux workshop
 
AndroidとSELinux
AndroidとSELinuxAndroidとSELinux
AndroidとSELinux
 
Bluestore
BluestoreBluestore
Bluestore
 
Node js
Node jsNode js
Node js
 

Viewers also liked

NPM THE GUIDE
NPM THE GUIDENPM THE GUIDE
NPM THE GUIDE
Kameron Tanseli
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
Vikash Singh
 
Package.json ( NodeJS )
Package.json ( NodeJS )Package.json ( NodeJS )
Package.json ( NodeJS )
Vivek Garg
 
npm: Modularizing your JavaScript development
npm: Modularizing your JavaScript developmentnpm: Modularizing your JavaScript development
npm: Modularizing your JavaScript development
Ruy Adorno
 
Working with npm packages
Working with npm packagesWorking with npm packages
Working with npm packages
Tomasz Bak
 
Angular 2 Seminar_(December 7/12/2015)
Angular 2 Seminar_(December 7/12/2015)Angular 2 Seminar_(December 7/12/2015)
Angular 2 Seminar_(December 7/12/2015)
Haim Michael
 
Npm
NpmNpm
Nodeconf npm 2011
Nodeconf npm 2011Nodeconf npm 2011
Nodeconf npm 2011
Florent Jaby ヅ
 
El proceso de tercerizacion económica (memes)
El proceso de tercerizacion económica (memes)El proceso de tercerizacion económica (memes)
El proceso de tercerizacion económica (memes)
Victor Morales
 
Grelha 06-elementos finitos de placas
Grelha 06-elementos finitos de placasGrelha 06-elementos finitos de placas
Grelha 06-elementos finitos de placas
Anderson Ricardo Cunha
 
Cómo recuperar datos perdidos después de android actualización
Cómo recuperar datos perdidos después de android actualizaciónCómo recuperar datos perdidos después de android actualización
Cómo recuperar datos perdidos después de android actualización
Jihosoft
 
Parcial de segundo corte
Parcial de segundo corteParcial de segundo corte
Parcial de segundo corteyomariver
 
Conclusiones y recomendaciones
Conclusiones y recomendacionesConclusiones y recomendaciones
Conclusiones y recomendaciones
Glamourland Accesories
 
Angular 2 - An Introduction
Angular 2 - An IntroductionAngular 2 - An Introduction
Angular 2 - An Introduction
NexThoughts Technologies
 
Twitter im Redaktionsalltag
Twitter im RedaktionsalltagTwitter im Redaktionsalltag
Twitter im Redaktionsalltag
Timo Stoppacher
 
Enterprise Node - Securing Your Environment
Enterprise Node - Securing Your EnvironmentEnterprise Node - Securing Your Environment
Enterprise Node - Securing Your Environment
Kurtis Kemple
 
Mercedes Sánchez - TripAdvisor #eHotelExperts
Mercedes Sánchez - TripAdvisor #eHotelExpertsMercedes Sánchez - TripAdvisor #eHotelExperts
Mercedes Sánchez - TripAdvisor #eHotelExperts
Laura Fernández @LauFerGar
 
Node Architecture and Getting Started with Express
Node Architecture and Getting Started with ExpressNode Architecture and Getting Started with Express
Node Architecture and Getting Started with Express
jguerrero999
 
congratulatory letter from GBCI.com
congratulatory letter from GBCI.comcongratulatory letter from GBCI.com
congratulatory letter from GBCI.com
max sh.
 

Viewers also liked (20)

NPM THE GUIDE
NPM THE GUIDENPM THE GUIDE
NPM THE GUIDE
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Package.json ( NodeJS )
Package.json ( NodeJS )Package.json ( NodeJS )
Package.json ( NodeJS )
 
npm: Modularizing your JavaScript development
npm: Modularizing your JavaScript developmentnpm: Modularizing your JavaScript development
npm: Modularizing your JavaScript development
 
Working with npm packages
Working with npm packagesWorking with npm packages
Working with npm packages
 
Angular 2 Seminar_(December 7/12/2015)
Angular 2 Seminar_(December 7/12/2015)Angular 2 Seminar_(December 7/12/2015)
Angular 2 Seminar_(December 7/12/2015)
 
Npm
NpmNpm
Npm
 
Nodeconf npm 2011
Nodeconf npm 2011Nodeconf npm 2011
Nodeconf npm 2011
 
El proceso de tercerizacion económica (memes)
El proceso de tercerizacion económica (memes)El proceso de tercerizacion económica (memes)
El proceso de tercerizacion económica (memes)
 
Grelha 06-elementos finitos de placas
Grelha 06-elementos finitos de placasGrelha 06-elementos finitos de placas
Grelha 06-elementos finitos de placas
 
Memoria2011 nexusenergia esp
Memoria2011 nexusenergia espMemoria2011 nexusenergia esp
Memoria2011 nexusenergia esp
 
Cómo recuperar datos perdidos después de android actualización
Cómo recuperar datos perdidos después de android actualizaciónCómo recuperar datos perdidos después de android actualización
Cómo recuperar datos perdidos después de android actualización
 
Parcial de segundo corte
Parcial de segundo corteParcial de segundo corte
Parcial de segundo corte
 
Conclusiones y recomendaciones
Conclusiones y recomendacionesConclusiones y recomendaciones
Conclusiones y recomendaciones
 
Angular 2 - An Introduction
Angular 2 - An IntroductionAngular 2 - An Introduction
Angular 2 - An Introduction
 
Twitter im Redaktionsalltag
Twitter im RedaktionsalltagTwitter im Redaktionsalltag
Twitter im Redaktionsalltag
 
Enterprise Node - Securing Your Environment
Enterprise Node - Securing Your EnvironmentEnterprise Node - Securing Your Environment
Enterprise Node - Securing Your Environment
 
Mercedes Sánchez - TripAdvisor #eHotelExperts
Mercedes Sánchez - TripAdvisor #eHotelExpertsMercedes Sánchez - TripAdvisor #eHotelExperts
Mercedes Sánchez - TripAdvisor #eHotelExperts
 
Node Architecture and Getting Started with Express
Node Architecture and Getting Started with ExpressNode Architecture and Getting Started with Express
Node Architecture and Getting Started with Express
 
congratulatory letter from GBCI.com
congratulatory letter from GBCI.comcongratulatory letter from GBCI.com
congratulatory letter from GBCI.com
 

Similar to Introduction to NPM and building CLI Tools with Node.js

Overview of Node JS
Overview of Node JSOverview of Node JS
Overview of Node JS
Jacob Nelson
 
Wrangling 3rd Party Installers from Puppet
Wrangling 3rd Party Installers from PuppetWrangling 3rd Party Installers from Puppet
Wrangling 3rd Party Installers from Puppet
Puppet
 
Node.js
Node.jsNode.js
3 Things Everyone Knows About Node JS That You Don't
3 Things Everyone Knows About Node JS That You Don't3 Things Everyone Knows About Node JS That You Don't
3 Things Everyone Knows About Node JS That You Don't
F5 Buddy
 
Introduction to package manager
Introduction to package managerIntroduction to package manager
Introduction to package manager
yashobantabai
 
Debian packaging
Debian packagingDebian packaging
Debian packaging
Knoldus Inc.
 
Deploying NPM packages with the Nix package manager
Deploying NPM packages with the Nix package managerDeploying NPM packages with the Nix package manager
Deploying NPM packages with the Nix package manager
Sander van der Burg
 
nuxt-en.pdf
nuxt-en.pdfnuxt-en.pdf
nuxt-en.pdf
ssuser65180a
 
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
Puppet
 
Puppet Camp LA 2/19/2015
Puppet Camp LA 2/19/2015Puppet Camp LA 2/19/2015
Puppet Camp LA 2/19/2015
ice799
 
Getting Started with Node.js
Getting Started with Node.jsGetting Started with Node.js
Getting Started with Node.js
Justin Reock
 
Conda: A Cross-Platform Package Manager for Any Binary Distribution (SciPy 2014)
Conda: A Cross-Platform Package Manager for Any Binary Distribution (SciPy 2014)Conda: A Cross-Platform Package Manager for Any Binary Distribution (SciPy 2014)
Conda: A Cross-Platform Package Manager for Any Binary Distribution (SciPy 2014)Aaron Meurer
 
Automating Mendix application deployments with Nix
Automating Mendix application deployments with NixAutomating Mendix application deployments with Nix
Automating Mendix application deployments with Nix
Sander van der Burg
 
Strategies for developing and deploying your embedded applications and images
Strategies for developing and deploying your embedded applications and imagesStrategies for developing and deploying your embedded applications and images
Strategies for developing and deploying your embedded applications and images
Mender.io
 
Making your app soar without a container manifest
Making your app soar without a container manifestMaking your app soar without a container manifest
Making your app soar without a container manifest
LibbySchulze
 
Steps to Install NPM and Node.js on Windows and MAC
Steps to Install NPM and Node.js on Windows and MACSteps to Install NPM and Node.js on Windows and MAC
Steps to Install NPM and Node.js on Windows and MAC
Inexture Solutions
 
Node Package Manager Tutorial | NPM Tutorial for Beginners | Express JS Tutor...
Node Package Manager Tutorial | NPM Tutorial for Beginners | Express JS Tutor...Node Package Manager Tutorial | NPM Tutorial for Beginners | Express JS Tutor...
Node Package Manager Tutorial | NPM Tutorial for Beginners | Express JS Tutor...
Simplilearn
 
Installing Software, Part 3: Command Line
Installing Software, Part 3: Command LineInstalling Software, Part 3: Command Line
Installing Software, Part 3: Command Line
Kevin OBrien
 
Create ReactJS Component & publish as npm package
Create ReactJS Component & publish as npm packageCreate ReactJS Component & publish as npm package
Create ReactJS Component & publish as npm package
Andrii Lundiak
 

Similar to Introduction to NPM and building CLI Tools with Node.js (20)

Overview of Node JS
Overview of Node JSOverview of Node JS
Overview of Node JS
 
Wrangling 3rd Party Installers from Puppet
Wrangling 3rd Party Installers from PuppetWrangling 3rd Party Installers from Puppet
Wrangling 3rd Party Installers from Puppet
 
Node.js
Node.jsNode.js
Node.js
 
3 Things Everyone Knows About Node JS That You Don't
3 Things Everyone Knows About Node JS That You Don't3 Things Everyone Knows About Node JS That You Don't
3 Things Everyone Knows About Node JS That You Don't
 
Introduction to package manager
Introduction to package managerIntroduction to package manager
Introduction to package manager
 
Debian packaging
Debian packagingDebian packaging
Debian packaging
 
Deploying NPM packages with the Nix package manager
Deploying NPM packages with the Nix package managerDeploying NPM packages with the Nix package manager
Deploying NPM packages with the Nix package manager
 
nuxt-en.pdf
nuxt-en.pdfnuxt-en.pdf
nuxt-en.pdf
 
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
 
Puppet Camp LA 2/19/2015
Puppet Camp LA 2/19/2015Puppet Camp LA 2/19/2015
Puppet Camp LA 2/19/2015
 
Getting Started with Node.js
Getting Started with Node.jsGetting Started with Node.js
Getting Started with Node.js
 
Conda: A Cross-Platform Package Manager for Any Binary Distribution (SciPy 2014)
Conda: A Cross-Platform Package Manager for Any Binary Distribution (SciPy 2014)Conda: A Cross-Platform Package Manager for Any Binary Distribution (SciPy 2014)
Conda: A Cross-Platform Package Manager for Any Binary Distribution (SciPy 2014)
 
Automating Mendix application deployments with Nix
Automating Mendix application deployments with NixAutomating Mendix application deployments with Nix
Automating Mendix application deployments with Nix
 
Strategies for developing and deploying your embedded applications and images
Strategies for developing and deploying your embedded applications and imagesStrategies for developing and deploying your embedded applications and images
Strategies for developing and deploying your embedded applications and images
 
Making your app soar without a container manifest
Making your app soar without a container manifestMaking your app soar without a container manifest
Making your app soar without a container manifest
 
Steps to Install NPM and Node.js on Windows and MAC
Steps to Install NPM and Node.js on Windows and MACSteps to Install NPM and Node.js on Windows and MAC
Steps to Install NPM and Node.js on Windows and MAC
 
Node Package Manager Tutorial | NPM Tutorial for Beginners | Express JS Tutor...
Node Package Manager Tutorial | NPM Tutorial for Beginners | Express JS Tutor...Node Package Manager Tutorial | NPM Tutorial for Beginners | Express JS Tutor...
Node Package Manager Tutorial | NPM Tutorial for Beginners | Express JS Tutor...
 
Installing Software, Part 3: Command Line
Installing Software, Part 3: Command LineInstalling Software, Part 3: Command Line
Installing Software, Part 3: Command Line
 
Ferrara Linux Day 2011
Ferrara Linux Day 2011Ferrara Linux Day 2011
Ferrara Linux Day 2011
 
Create ReactJS Component & publish as npm package
Create ReactJS Component & publish as npm packageCreate ReactJS Component & publish as npm package
Create ReactJS Component & publish as npm package
 

Recently uploaded

From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 

Recently uploaded (20)

From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 

Introduction to NPM and building CLI Tools with Node.js

  • 2. Introduction to Agenda ● What is NPM? ● Understanding package.json ● Where to find Packages? ● Installing Packages ● Writing your own Packages ● Command Line ● Publishing to NPM ● Questions & Exercises
  • 3. Introduction to What is NPM? First Time Using NPM
  • 4. Introduction to What is NPM? ● A Node Package Manager ● No other Package Manager comes closer ● Is also used by developers who don’t use Node.js at all ● Created by Isaac Z. Schlueter ● Breeze to use ● Recently made into a company, NPM Inc. by Isaac ● Free and Open Source!
  • 5. Introduction to Understanding package.json ● It is a valid JSON object ● name and version fields are required, the combination makes a unique identifier for the package ● Some used fields in package.json ○ description ○ keywords ○ homepage ○ bugs ○ license ○ author & contributors ○ main ○ bin ○ dependencies ○ scripts - {start, preinstall}
  • 6. Introduction to Where to find Packages? https://npmjs.org
  • 7. Introduction to Installing Packages ● npm comes along with node.js ● to install a package run: ○ npm install <package-name> ○ npm install <tarball file> ○ npm install <tarball url> ● install a package globally ○ npm install -g <package-name> Note: Global installation makes the package available globally irrespective of the directory you installed it from.
  • 8. Introduction to Writing your own packages ● Install Grunt , the javascript task runner ○ npm install -g grunt-cli ● Run command : ○ grunt-init node ● Answer few questions and you are ready with a nice package.json file and main .js file for your package.
  • 9. Introduction to Writing your own packages The generated folder structure should look something like this: Write the code in the .js file created, you can also create many more files as per your need.
  • 10. Introduction to Writing your own packages Some guidelines to keep in mind when writing new packages: ● Don’t reinvent the wheel ● Try to contribute to other packages whenever possible ● If you are writing a utility package, then multiple exports should be used ● If your package needs to maintain a state then its good to export a constructor ● Most Important thing, KEEP IT COOL!
  • 11. Introduction to Command Line To be able to use your package through command line, you need to specify ‘bin’ in package.json as follows: "bin": { "nodeart": "lib/nodeArt.js" } Also add this #! /usr/bin/env node at the top of “lib/nodeArt.js” file. This tells how the file should be executed. As above, ‘nodeart’ will be the command available to you when you install the package on your machine.
  • 12. Introduction to Command Line You can receive the arguments passed from command line in process.argv array. First two values in the array are pre-defined : [ 'node', '/opt/node-v0.10.5-linux-x64/bin/nodeArt'] The actual arguments being passed will be available at indexes greater than 1. So if you run nodeart ‘suroor wijdan’, the process.argv array will be: [ 'node', '/opt/node-v0.10.5-linux-x64/bin/nodeArt', ‘suroor wijdan’]
  • 13. Introduction to Command Line So its better to slice the array and store the arguments in another variable: var argumentsPassed = process.argv.slice(2);
  • 14. Introduction to Publishing to NPM To publish on NPM, you just need to have an account on it. To make an account run the following command: Once you have the account ready, just run the below command from project root to publish your module: And thats all, everything else will be taken care of by NPM registry. npm adduser //will ask for username, email and password npm publish
  • 17. Introduction to References 1. NPM Logo - https://npmjs.org 2. https://npmjs.org/doc/ 3. Image Credit - http://nodejsreactions.tumblr.com/post/64781824365/first-time-using-npm 4. Grunt Logo - http://gruntjs.com