The many uses of npm

Fluent, 2016-03-09

Who is this guy?

Laurie Voss

CTO,           

@seldo

What are we talking about?

All the stuff you can do with npm these days

npm users are mostly newbies

This is a tour of

 really useful stuff

What is npm anyway?

  • CLI
  • Registry
  • Website
  • Community
  • Company

1: a command line client (CLI)

The CLI manages your code

  • Dependencies
  • Life cycle
  • Tooling

2: a registry

3: a website

4: a community

npm <3 you

5: a company

npm is a company that sells goods and services

Marketing suggested I include this language.

  1. Hosted private packages
  2. npm On-Site

Goal: reduce developer friction

npm is not (very) opinionated

The many uses of npm

  • building a project
  • sharing a project
  • managing dependencies
  • lifecycle management
  • a platform for tools

1: Building a project

npm init

npm init auto detects your code

~/.npm-init.js and PromZard

npm install

  • npm install --save
  • npm install --save-dev

npm install

--save-optional

npm install

--save --save-bundle

npm isntall

Offline installs

npm install --cache-min 999999

Simple run scripts

  • npm stop
  • npm start
  • npm test
scripts: {
    "start": "node ./index.js"
}

2: sharing a project

npm publish

npm publish --access=restricted

npm version

  • npm version major
  • npm version minor
  • npm version patch
  • npm version major -m "bump to version %s"

npm owner

npm organizations

npm team

  • npm team create
  • npm team destroy
  • npm team add
  • npm team rm
  • npm team ls

npm access

  • npm access grant
  • npm access revoke
  • npm access ls-packages
  • npm access ls-collaborators

Semantic Versioning

SemVer

1.5.6

Major

Minor

Patch

Breaking

Feature

Fix

npm shrinkwrap

3: managing dependencies

npm dedupe

npm prune

npm link

npm update

npm outdated

4: lifecycle management

dist tags

  • npm publish --tag
  • npm dist-tag
  • npm install mypackage@latest
  • npm install mypackage@beta
  • npm install mypackage@lts

npm deprecate

npm run $anything

npm run scripts

  • npm run dev:setup
  • npm run db:reset
  • npm run debug

Lifecycle hooks

publish:   prepublish, publish, postpublish
install:      preinstall, install, postinstall
uninstall: preuninstall, uninstall, postuninstall
version:   preversion, version, postversion
test:          pretest, test, posttest
stop:        prestop, stop, poststop
start:        prestart, start, poststart
restart:    prerestart, restart, postrestart

Run scripts have devDependencies in path

5: a platform for tooling

Simple tools in a bigger ecosystem

Less, Sass and CSS

Babel

Webpack and Browserify

standard

More CSS tricks

http://sethvincent.com/css-via-npm/

semantic-release

npm install -g semantic-release

Downstream npm features

npm On-Site

Greenkeeper

greenkeeper.io

Node Security Project

npm install nsp

Snyk and BitHound

Tonic

tonicdev.com

npm is more than install

Unrelated:

If you're an LGBTQ person in technology, you may like this Slack!

npm loves you

Thanks!

 

@seldo

laurie@npmjs.com

Fluent 2016: the many uses of npm

By seldo

Fluent 2016: the many uses of npm

A tour of npm's most useful commands, starting at the stuff everybody knows down to the stuff almost nobody knows.

  • 4,108