`
### `types: major, minor, patch`
- ### major: breaking changes
- ### minor: feature add
- ### patch: bug fix, docs
---
class: center, middle
# npm wants to make your life easy
---
class: top, left
## automate all the things
# `npm run $anything`
### - `test`, `start`
### - customize!



---
class: middle, center
# lifecycle events




---
class: middle, center
## `npm i --save-dev husky`


---
class: middle, center
# run scripts are composable!



---
class: middle, center
# get stuff for free
# `npm run env`
### `config` and `package.json` as variables



---
class: middle, center
# `npm i -D shelljs`

---
class: center, middle
# never install something globally again
---
class: middle, center
# why run scripts?
--
# because they are **versioned**
---
class: top, left
# let's look at an example
{
"...": "...",
"scripts": {
"test": "npm run test:backend && npm run test:frontend",
"posttest": "standard",
"test:backend": "lab --verbose --assert code --timeout 5000",
"test:frontend": "karma start",
"...": "..."
},
"devDependencies": {
"...": "...",
"karma": "^1.1.1",
"lab": "^13.0.1",
"standard": "^10.0.2",
"...": "..."
}
}
---
class: center, middle
background-image: url(public/img/pbn_barn.jpg)
background-color: #FFE4C4

---
class: center, middle
background-image: url(public/img/pbn_barn.jpg)
background-color: #FFE4C4
# 39,692 publishes/week
---
class: center, middle
background-image: url(public/img/pbn_barn.jpg)
background-color: #FFE4C4

---
class: center, middle
background-image: url(public/img/pbn_barn.jpg)
background-color: #FFE4C4
# 4,685 new packages last week
---
class: center, middle
background-image: url(public/img/pbn_horses.jpg)
background-color: #FFE4C4
# ~160 people publish their first package every week
---
class: center, middle
background-image: url(public/img/pbn_horses.jpg)
background-color: #FFE4C4
# 102,460 publishers
---
class: top, left
## create a package.json
# `npm init`
- ### knows your deps from node_modules
- ### knows your repository from git repo
- ### always adds keys, never deletes

---
class: top, left
## create a package.json with defaults
# `npm init --yes`

---
class: top, left
## customize npm init questions
# `~/.npm-init.js`
### enforce license and best practices



---
class: center, middle
# check your package before you publish!
# `npm pack`
# `tar xvzf pkg.tar.gz`
---
class: center, middle
# `np` by sindresorhus

.citation[https://github.com/sindresorhus/np]
---
class: center, middle
background-image: url(public/img/pbn_swans.jpg)
background-color: #FFE4C4
# unpublishes
---
class: center, middle
background-image: url(public/img/pbn_swans.jpg)
background-color: #FFE4C4
# left-pad
---
class: center, middle
background-image: url(public/img/pbn_swans.jpg)
background-color: #FFE4C4

---
class: center, middle
background-image: url(public/img/pbn_swans.jpg)
background-color: #FFE4C4

#### [http://blog.npmjs.org/post/141905368000/changes-to-npms-unpublish-policy](http://blog.npmjs.org/post/141905368000/changes-to-npms-unpublish-policy)
---
class: center, middle
background-image: url(public/img/pbn_swans.jpg)
background-color: #FFE4C4
# you can only unpublish within 24hrs
---
class: center, middle
background-image: url(public/img/pbn_swans.jpg)
background-color: #FFE4C4

---
class: center, middle
background-image: url(public/img/pbn_swans.jpg)
background-color: #FFE4C4
# dissociate and deprecate
---
class: middle, center
background-image: url(public/img/pbn_swans.jpg)
background-color: #FFE4C4

---
class: middle, center
# scoped packages
## (fancy way of saying namespaced packages!)
---
class: top, left
## scoped packages
# `npm i @scope/name`

--
### scoped packages are private by default but you can make them public:
### `npm publish --access=public`
---
class: center, middle
# we now have search and download stat support for scopes!



---
class: center, middle

---
class: center, middle
# you *already* have a scope!
## (hint: it's your user name!)
---
class: top, left
## private packages
## `npm init --scope=`
### Use your private modules side by side with modules from the public registry



---
class: top, left
## npm organizations
# `npm team`
- ### create teams and add members
- ### grant and revoke access to packages via teams

---
class: center, middle
background-image: url(public/img/pbn_swans.jpg)
background-color: #FFE4C4
# the registry is immutable
---
class: center, middle
background-image: url(public/img/pbn_swans.jpg)
background-color: #FFE4C4
# the registry is reliable
---
class: center, middle
background-image: url(public/img/pbn_swans.jpg)
background-color: #FFE4C4

# [http://ping.npmjs.com/](http://ping.npmjs.com/)
---
class: center, middle
background-image: url(public/img/pbn_swans.jpg)
background-color: #FFE4C4
# the registry is fast
---
class: center, middle
background-image: url(public/img/pbn_swans.jpg)
background-color: #FFE4C4

---
class: center, middle
background-image: url(public/img/pbn_swans.jpg)
background-color: #FFE4C4
## on an empty cache
# the registry is ~75% faster than git
---
class: center, middle
background-image: url(public/img/pbn_ocean.jpg)
background-color: #FFE4C4
# the registry is HUGE
---
class: center, middle
background-image: url(public/img/pbn_ocean.jpg)
background-color: #FFE4C4

.citation[source: http://modulecounts.com, accessed: 29 nov 2016]
---
class: center, middle
background-image: url(public/img/pbn_ocean.jpg)
background-color: #FFE4C4
# npm is the largest package registry IN THE WORLD
---
class: top, left
# npm on-site
## run your own on-premises npm registry
### `npm login`
### ` --registry=http://reg.amazing.com`



---
class: middle, center

---
class: center, middle
background-image: url(public/img/pbn_field.jpg)
background-color: #FFE4C4
# npm is being used for a lot of things we never expected
---
class: center, middle
background-image: url(public/img/pbn_field.jpg)
background-color: #FFE4C4

---
class: center, middle
background-image: url(public/img/pbn_field.jpg)
background-color: #FFE4C4

---
class: center, middle
background-image: url(public/img/pbn_field.jpg)
background-color: #FFE4C4

---
class: center, middle
background-image: url(public/img/pbn_field.jpg)
background-color: #FFE4C4

---
class: center, middle
background-image: url(public/img/pbn_ship.jpg)
background-color: #FFE4C4
# and so can you!
---
class: center, middle
background-image: url(public/img/pbn_ship.jpg)
background-color: #FFE4C4
# public APIs
---
class: center, middle
background-image: url(public/img/pbn_ship.jpg)
background-color: #FFE4C4
# downloads API
]
.citation[http://blog.npmjs.org/post/92574016600/numeric-precision-matters-how-npm-download-counts]
---
class: center, middle
background-image: url(public/img/pbn_ship.jpg)
background-color: #FFE4C4



.citation[https://github.com/npm/registry/blob/master/docs/download-counts.md]
---
class: center, middle
background-image: url(public/img/pbn_ship.jpg)
background-color: #FFE4C4
# search API

---
class: center, middle
background-image: url(public/img/pbn_ship.jpg)
background-color: #FFE4C4
# registry changes-stream
# [https://replicate.npmjs.com](https://replicate.npmjs.com)
---
class: center, middle
background-image: url(public/img/pbn_ship.jpg)
background-color: #FFE4C4
## write a registry follower

#### [https://github.com/npm/registry/blob/master/docs/follower.md](https://github.com/npm/registry/blob/master/docs/follower.md)
---
class: center, middle
background-image: url(public/img/pbn_ship.jpg)
background-color: #FFE4C4
# webhooks
---
class: center, middle
background-image: url(public/img/pbn_ship.jpg)
background-color: #FFE4C4
## [https://github.com/npm/registry/](https://github.com/npm/registry/)

---
class: center, middle
background-image: url(public/img/pbn_ship.jpg)
background-color: #FFE4C4
# we are so excited to see what you build
---
class: center, middle
# update your npm!
# `npm i npm@latest -g`
---
class: center, middle
# you can use any npm with any node version
--
# so you should always use the most up to date version
---
class: center, middle
background-image: url(public/img/pbn_ship.jpg)
background-color: #FFE4C4

---
class: center, middle
# thanks!
## `me => @ag_dubs`
## bit.ly/fwdays-2017


