SlideShare a Scribd company logo
NPM
Beyond npm i
Pieter Herroelen
@piether
Npm: beyond 'npm i'
Npm: beyond 'npm i'
NPM?
NPM 2 vs NPM 3
Npm: beyond 'npm i'
Npm: beyond 'npm i'
Npm: beyond 'npm i'
NPM scripts
"scripts": {
"postinstall": "echo "Thanks for installing my package ""
},
● prepublish: Run BEFORE the package is published. (Also run on local npm install without any arguments.)
● publish, postpublish: Run AFTER the package is published.
● preinstall: Run BEFORE the package is installed
● install, postinstall: Run AFTER the package is installed.
● preuninstall, uninstall: Run BEFORE the package is uninstalled.
● postuninstall: Run AFTER the package is uninstalled.
● preversion, version: Run BEFORE bump the package version.
● postversion: Run AFTER bump the package version.
● pretest, test, posttest: Run by the npm test command.
● prestop, stop, poststop: Run by the npm stop command.
● prestart, start, poststart: Run by the npm start command.
● prerestart, restart, postrestart: Run by the npm restart command. Note: npm restart will run the stop and
start scripts if no restart script is provided.
(https://docs.npmjs.com/misc/scripts)
Predefined script names
"scripts": {
"grunt-version" : "grunt --version"
},
$ grunt --version
grunt-cli v0.1.13
grunt v1.0.0
$ npm run grunt-version
> npm-test@1.0.0 grunt /Users/pieter/projects/npm-test
> grunt --version
grunt-cli v1.2.0
grunt v1.0.1
Custom script names
How to use NPM as a build tool
http://blog.keithcirkel.co.uk/how-to-use-npm-as-a-build-tool/
NPM version syntax
MAJOR.MINOR.PATCH
MAJOR.MINOR.PATCH
= Semantic versioning aka semver
1.2.3 - 2.3.4
Minimum
version
Comparator
( < or <= )
Maximum
version
1.2.3 - 2.3.4
1.2.3 <= 2.3.4
= Hyphen range
1.x
Minimum
version
Comparator
( < or <= )
Maximum
version
1.x
1.0.0 < 2.0.0
= Hyphen range
~1.2.3
Minimum
version
Comparator
( < or <= )
Maximum
version
~1.2.3
1.2.3 < 1.3.0
= tilde range
^1.2.3
Minimum
version
Comparator
( < or <= )
Maximum
version
^1.2.3
1.2.3 < 2.0.0
= caret range (default)
^0.2.3
Minimum
version
Comparator
( < or <= )
Maximum
version
^0.2.3
0.2.3 < 0.3.0
NPM repositories
Module
Module author:
npm publish
Your app
You:
npm install
March 23rd, 2016
Npm: beyond 'npm i'
Npm: beyond 'npm i'
babel leftpad
Module
Module author:
npm unpublish
Your app
You:
npm install babel
Npm: beyond 'npm i'
Npm: beyond 'npm i'
You cannot publish over the previously published
version.
babel leftpad
^0.0.3
Npm: beyond 'npm i'
^0.0.3
Minimum
version
Comparator
( < or <= )
Maximum
version
^0.0.3
0.0.3 < 0.0.4
Module
Module author:
npm publish
Your app
You:
npm install
Private NPM
repository
Module
Module author:
npm unpublish
Your app
You:
npm install
Private NPM
repository
NPM shrinkwrap
B
(external)
C
(external)
A
B
(1.0.0)
C
(1.0.0)
1.0.0 1.0.0
B
(external)
C
(external)
A
B
(1.0.0)
C
(1.0.0)
C
(1.0.1)
1.0.0 1.0.1
$ npm shrinkwrap
wrote npm-shrinkwrap.json
B
(external)
C
(external)
A
B
(1.0.0)
C
(1.0.0)
C
(1.0.1)
1.0.0 1.0.0
Your own NPM repo + shrinkwrap =
reproducible builds :)
Scoped packages
Module
@neoscores/some-
module
Your colleague:
npm publish
Your app
You:
npm login
npm install @neoscores/some-module
Thank you
(https://www.neoscores.com/jobs)

More Related Content

What's hot (19)

PDF
S&T What I know about Node 110817
Dan Dineen
 
PDF
Advanced front-end automation with npm scripts
k88hudson
 
PPTX
Modern Development Tools
Ye Maw
 
PDF
Magento 2 Capistrano Deploy
Duke Dao
 
ODP
Groovy shell scripting
Georg Berky
 
PDF
Capistrano deploy Magento project in an efficient way
Sylvain Rayé
 
PDF
Introduction to Express and Grunt
Peter deHaan
 
PDF
Introduction of Pharo 5.0
Masashi Umezawa
 
PDF
Frontend Build Tools - CC FE & UX
JWORKS powered by Ordina
 
PDF
GDG Kraków - Intro to front-end automation using bower.js & grunt.js
Dominik Prokop
 
PDF
Docker
Kamil Grabowski
 
PDF
OSDC.no 2015 introduction to node.js workshop
leffen
 
PDF
Continuous Integration for front-end JavaScript
Lars Thorup
 
PPTX
Modern web technologies
Simeon Prusiyski
 
PPTX
Gulp and bower Implementation
Prashant Shrestha
 
PDF
Helpful pre commit hooks for Python and Django
roskakori
 
PDF
Getting started with gulpjs
unmesh dusane
 
PDF
Beyond Puppet
Kris Buytaert
 
PDF
Warsztaty ansible
gnosek
 
S&T What I know about Node 110817
Dan Dineen
 
Advanced front-end automation with npm scripts
k88hudson
 
Modern Development Tools
Ye Maw
 
Magento 2 Capistrano Deploy
Duke Dao
 
Groovy shell scripting
Georg Berky
 
Capistrano deploy Magento project in an efficient way
Sylvain Rayé
 
Introduction to Express and Grunt
Peter deHaan
 
Introduction of Pharo 5.0
Masashi Umezawa
 
Frontend Build Tools - CC FE & UX
JWORKS powered by Ordina
 
GDG Kraków - Intro to front-end automation using bower.js & grunt.js
Dominik Prokop
 
OSDC.no 2015 introduction to node.js workshop
leffen
 
Continuous Integration for front-end JavaScript
Lars Thorup
 
Modern web technologies
Simeon Prusiyski
 
Gulp and bower Implementation
Prashant Shrestha
 
Helpful pre commit hooks for Python and Django
roskakori
 
Getting started with gulpjs
unmesh dusane
 
Beyond Puppet
Kris Buytaert
 
Warsztaty ansible
gnosek
 

Viewers also liked (9)

PDF
Использовании TypeScript для Node.js
FullStackJS
 
KEY
Nodeconf npm 2011
Florent Jaby ヅ
 
PDF
Using a hypermedia API with Angular.js
Pieter Herroelen
 
PDF
Jaap : node, npm & grunt
Bertrand Chevrier
 
PPTX
Startup JavaScript 8 - NPM, Express.JS
Circulus
 
PDF
Node.js & Twitter Bootstrap Crash Course
Aaron Silverman
 
PDF
How to Write Node.js Module
Fred Chien
 
PDF
Harnessing the power of YARN with Apache Twill
Terence Yim
 
Использовании TypeScript для Node.js
FullStackJS
 
Nodeconf npm 2011
Florent Jaby ヅ
 
Using a hypermedia API with Angular.js
Pieter Herroelen
 
Jaap : node, npm & grunt
Bertrand Chevrier
 
Startup JavaScript 8 - NPM, Express.JS
Circulus
 
Node.js & Twitter Bootstrap Crash Course
Aaron Silverman
 
How to Write Node.js Module
Fred Chien
 
Harnessing the power of YARN with Apache Twill
Terence Yim
 
Ad

Similar to Npm: beyond 'npm i' (20)

PDF
NPM.pdf
Bareen Shaikh
 
PDF
Workshop 3: JavaScript build tools
Visual Engineering
 
PPTX
Anton Cherednikov "Modules and Artifacts in NPM"
LogeekNightUkraine
 
PDF
Manage custom kernel builds
Marian Marinov
 
PPTX
Configure jasmine and karma for code coverage
Deepak More
 
PDF
Nodejs in Production
William Bruno Moraes
 
PDF
How I hack on puppet modules
Kris Buytaert
 
PDF
Wrangling 3rd Party Installers from Puppet
Puppet
 
PDF
Smoking docker
Workhorse Computing
 
PDF
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
Simon Boulet
 
PPTX
NodeJs Session03
Jainul Musani
 
PDF
Zero Downtime Deployment with Ansible
Stein Inge Morisbak
 
PDF
Getting Started with Ansible - Jake.pdf
ssuserd254491
 
PPTX
Solidity intro
Angello Pozo
 
PPTX
Analysis of an exploited npm package
Parth Parmar
 
PDF
May The Nodejs Be With You
Dalibor Gogic
 
KEY
Deploying and maintaining your software with RPM/APT
Joshua Thijssen
 
PDF
Npmwormdisclosure
Andrey Apuhtin
 
PPTX
Installing and updating software packages [autosaved]
ANIMESHKUMARSINHA2
 
NPM.pdf
Bareen Shaikh
 
Workshop 3: JavaScript build tools
Visual Engineering
 
Anton Cherednikov "Modules and Artifacts in NPM"
LogeekNightUkraine
 
Manage custom kernel builds
Marian Marinov
 
Configure jasmine and karma for code coverage
Deepak More
 
Nodejs in Production
William Bruno Moraes
 
How I hack on puppet modules
Kris Buytaert
 
Wrangling 3rd Party Installers from Puppet
Puppet
 
Smoking docker
Workhorse Computing
 
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
Simon Boulet
 
NodeJs Session03
Jainul Musani
 
Zero Downtime Deployment with Ansible
Stein Inge Morisbak
 
Getting Started with Ansible - Jake.pdf
ssuserd254491
 
Solidity intro
Angello Pozo
 
Analysis of an exploited npm package
Parth Parmar
 
May The Nodejs Be With You
Dalibor Gogic
 
Deploying and maintaining your software with RPM/APT
Joshua Thijssen
 
Npmwormdisclosure
Andrey Apuhtin
 
Installing and updating software packages [autosaved]
ANIMESHKUMARSINHA2
 
Ad

Recently uploaded (20)

PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PPTX
Transforming Insights: How Generative AI is Revolutionizing Data Analytics
LetsAI Solutions
 
PPTX
Build a Custom Agent for Agentic Testing.pptx
klpathrudu
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PDF
AI Prompts Cheat Code prompt engineering
Avijit Kumar Roy
 
PDF
Ready Layer One: Intro to the Model Context Protocol
mmckenna1
 
PDF
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PDF
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
PDF
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
PDF
Salesforce Experience Cloud Consultant.pdf
VALiNTRY360
 
PPTX
Smart Doctor Appointment Booking option in odoo.pptx
AxisTechnolabs
 
PDF
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
PPTX
BB FlashBack Pro 5.61.0.4843 With Crack Free Download
cracked shares
 
PDF
UITP Summit Meep Pitch may 2025 MaaS Rebooted
campoamor1
 
PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PDF
NPD Software -Omnex systems
omnex systems
 
PPTX
Prompt Like a Pro. Leveraging Salesforce Data to Power AI Workflows.pptx
Dele Amefo
 
PDF
intro_to_cpp_namespace_robotics_corner.pdf
MohamedSaied877003
 
PPTX
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
Transforming Insights: How Generative AI is Revolutionizing Data Analytics
LetsAI Solutions
 
Build a Custom Agent for Agentic Testing.pptx
klpathrudu
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
AI Prompts Cheat Code prompt engineering
Avijit Kumar Roy
 
Ready Layer One: Intro to the Model Context Protocol
mmckenna1
 
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
Salesforce Experience Cloud Consultant.pdf
VALiNTRY360
 
Smart Doctor Appointment Booking option in odoo.pptx
AxisTechnolabs
 
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
BB FlashBack Pro 5.61.0.4843 With Crack Free Download
cracked shares
 
UITP Summit Meep Pitch may 2025 MaaS Rebooted
campoamor1
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
NPD Software -Omnex systems
omnex systems
 
Prompt Like a Pro. Leveraging Salesforce Data to Power AI Workflows.pptx
Dele Amefo
 
intro_to_cpp_namespace_robotics_corner.pdf
MohamedSaied877003
 
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 

Npm: beyond 'npm i'