+ - 0:00:00
Notes for current slide
Notes for next slide

you don't know

npm logo

1 / 105

http://bit.ly/fwdays-2017

(gh-pages: ashleygwilliams/fwdays-2017)

2 / 105

everyday around 1,800,000 install events occur.

3 / 105

each install is around 70 packages.

4 / 105

1,800,000 * 70

5 / 105

126,000,000

6 / 105

that's a lot of packages

7 / 105

hi my name is @ag_dubs

space invader ghost dolphin

8 / 105

real-eyes

9 / 105

if you have some 💸 you can give it to us

10 / 105

if you have some 💸 you can give it to us

we'll use it to keep the registry running 🏃🏿

11 / 105

wombat

23 humans work at npm

12 / 105

CLI

Registry

Website

14 / 105

CLI

✨Registry✨

Website

15 / 105

over the last year

70 billion

package downloads occured

https://twitter.com/seldo/status/845094537752014852. 23 March 2017.

16 / 105

stuff everybody knows

npm install

18 / 105

stuff not everyone knows

i dont know

19 / 105

npm isntall

20 / 105

add deps from the CLI

npm i --save

npm i --save-dev

disk disk disk

21 / 105

add deps from the CLI

npm i -S

npm i -D

disk disk disk

22 / 105

show the dep tree

npm ls

list tree list

23 / 105

show just primary deps

npm ls --depth=0

list list list

24 / 105

npm prune

25 / 105

npm... global cache?

.npm/

modules are stored in the home directory

... but you can't use this offline because it still hits the network

26 / 105

npm install offline

npm install --cache-min 999999

we should probably just alias this to:

npm install --offline

money money money

27 / 105

npm install offline

npm pack

npm install my-pkg.tgz

create a tarball out of any package and then use install directly on the tarball

shirt soon suitcase

28 / 105

pack your deps!

bundledDependencies

pack doesn't add your pkg's deps BUT

bundled deps are added to the tarball!

suitcase soon suitcase

29 / 105
  • dependencies juggling

  • devDependencies hammer wrench

  • optionalDependencies ghost

  • peerDependencies plug

30 / 105

lock down your deps

npm shrinkwrap

shrinkwrap

31 / 105

update your shrinkwrap

--save and --save-dev

- don't need to shrinkwrap everytime

- new with npm3!

lock-pen new lock-pen

32 / 105

why not a default feature?

33 / 105

we believe in semver

want to believe

34 / 105

semver.npmjs.com

semverdotnpmjs

35 / 105

semver made easy

npm version <type>

types: major, minor, patch

  • major: breaking changes

  • minor: feature add

  • patch: bug fix, docs

36 / 105

npm wants to make your life easy

37 / 105

automate all the things

npm run $anything

- test, start

- customize!

theater runner theater

38 / 105

lifecycle events

lifecycle events

seedling plant tree

39 / 105

npm i --save-dev husky

husky husky

40 / 105

run scripts are composable!

score score score

41 / 105

get stuff for free

npm run env

config and package.json as variables

sparkles free sparkles

42 / 105

npm i -D shelljs

shelljs

43 / 105

never install something globally again

44 / 105

why run scripts?

45 / 105

why run scripts?

because they are versioned

46 / 105

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",
    "...": "..."
  }
}
47 / 105

publishes

48 / 105

39,692 publishes/week

49 / 105

new packages

50 / 105

4,685 new packages last week

51 / 105

~160 people publish their first package every week

52 / 105

102,460 publishers

53 / 105

create a package.json

npm init

  • knows your deps from node_modules

  • knows your repository from git repo

  • always adds keys, never deletes

chick

54 / 105

create a package.json with defaults

npm init --yes

yes

55 / 105

customize npm init questions

~/.npm-init.js

enforce license and best practices

question art question

56 / 105

check your package before you publish!

npm pack

tar xvzf pkg.tar.gz

57 / 105

np by sindresorhus

np

https://github.com/sindresorhus/np

58 / 105

unpublishes

59 / 105

left-pad

60 / 105

left-pad

61 / 105

you can only unpublish within 24hrs

63 / 105

meta issue

64 / 105

dissociate and deprecate

65 / 105

npm deprecate

66 / 105

scoped packages

(fancy way of saying namespaced packages!)

67 / 105

scoped packages

npm i @scope/name

telescope

68 / 105

scoped packages

npm i @scope/name

telescope

scoped packages are private by default but you can make them public:

npm publish --access=public

69 / 105

we now have search and download stat support for scopes!

70 / 105

old bug

71 / 105

you already have a scope!

(hint: it's your user name!)

72 / 105

private packages

npm init --scope=<usrname>

Use your private modules side by side with modules from the public registry

lock dancers lock

73 / 105

npm organizations

npm team

  • create teams and add members

  • grant and revoke access to packages via teams

team

74 / 105

the registry is immutable

75 / 105

the registry is reliable

76 / 105

the registry is fast

78 / 105

fast

79 / 105

on an empty cache

the registry is ~75% faster than git

80 / 105

the registry is HUGE

81 / 105

module counts

source: http://modulecounts.com, accessed: 29 nov 2016

82 / 105

npm is the largest package registry IN THE WORLD

83 / 105

npm on-site

run your own on-premises npm registry

npm login

--registry=http://reg.amazing.com

runner office runner

84 / 105

npme addons

85 / 105

npm is being used for a lot of things we never expected

86 / 105

greenkeeper

87 / 105

npms

88 / 105

yarn

89 / 105

cnpm

90 / 105

and so can you!

91 / 105

public APIs

92 / 105

search API

search api

95 / 105

registry changes-stream

https://replicate.npmjs.com

96 / 105

webhooks

98 / 105

we are so excited to see what you build

100 / 105

update your npm!

npm i npm@latest -g

101 / 105

you can use any npm with any node version

102 / 105

you can use any npm with any node version

so you should always use the most up to date version

103 / 105

npm

104 / 105

thanks!

me => @ag_dubs

bit.ly/fwdays-2017

space invader ghost dolphin

105 / 105

http://bit.ly/fwdays-2017

(gh-pages: ashleygwilliams/fwdays-2017)

2 / 105
Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow