`
### `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
# `npm i -D shelljs`

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



---
class: center, middle
# never install something globally again



--
#### ok fine, maybe *sometimes*
---
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 --assert code --timeout 5000",
"test:frontend": "karma start",
"...": "..."
},
"devDependencies": {
"...": "...",
"karma": "^1.1.1",
"lab": "^13.0.1",
"standard": "^10.0.2",
"...": "..."
}
}
---
class: middle, left
## don't hardcode node_modules
{
"...": "...",
"scripts": {
"start": "./node_modules/mocha/bin/mocha"
},
"...": "..."
}
---
class: middle, left
## don't hardcode node_modules
{
"...": "...",
"scripts": {
"start": "mocha"
},
"...": "..."
}
---
class: center, middle
# cute dog break!

---
class: center, middle

---
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: left, middle
# `.npmignore`
### - will match your .gitignore if no .npmignore
### - an empty .npmignore will override a .gitignore
### - you can't ignore some things, like package.json or a README
---
class: left, middle
# `"files": [...]`
### - add as an array to your package.json
### - list the files that should be included
### - some things are included even if they aren't listed like package.json or a README
---
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

.citation[[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: middle, center
# npm orgs are free for public packages!



---
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

.citation[https://github.com/npm/registry/blob/master/docs/REGISTRY-API.md#get-v1search]
---
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)
.citation[https://github.com/jcrugzz/changes-stream]
---
class: center, middle
background-image: url(public/img/pbn_ship.jpg)
background-color: #FFE4C4
## write a registry follower

.citation[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

.citation[https://github.com/npm/registry/tree/master/docs/hooks]
---
class: center, middle
background-image: url(public/img/pbn_ship.jpg)
background-color: #FFE4C4
# notifications in slack

.citation[https://github.com/npm/captain-hook]
---
class: center, middle
background-image: url(public/img/pbn_ship.jpg)
background-color: #FFE4C4

---
class: center, middle
background-image: url(public/img/pbn_ship.jpg)
background-color: #FFE4C4
.wombat[# `npm i wombat -g`]
.wombat[# `wombat hook add `]
---
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: left, middle
# npm 5 is coming soon!
- ### complete cache rewrite
- ### `--prefer-offline` and `--offline` install flags
- ### shrinkwrap `integrity` field
- ### it's fast as heck ;)
.citation[WIP changelog: https://github.com/npm/npm/pull/16244]
---
class: center, middle
---
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


