class: center, middle # you don't know  --- class: center, middle ## http://bit.ly/you-dont-know-npm ## http://github.com/ashleygwilliams/you-dont-know-npm --- class: center, middle # hi my name is @ag_dubs    --- class: center, middle # developer community and content manager --- class: center, middle # ?????lolwat  --- class: center, middle # if you don't understand how npm works    -- # that's my problem --  --- class: center, middle ## stuff everybody knows # `npm install` --- class: center, middle ## stuff not everyone knows  --- 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 ## add deps from the CLI # `npm i --save` # `npm i --save-dev`    --- class: top, left ## add deps from the CLI # `npm i -S` # `npm i -D`    --- class: top, left ## npm... global cache? # `.npm/` ## modules are stored in the home directory ### ... but you can't use this offline because it still hits the network  --- ## npm install offline ### `npm install --cache-min 999999` ### we should probably just alias this to: ### `npm install --offline`    --- class: top, left ## lock down your deps # `npm shrinkwrap`  --- class: top, left ## lock down your deps # `npm shrinkwrap` - ### deploy to production EXACTLY what you used in dev - ### locks every version of every package and all dependencies in node_modules --- class: center, middle # why not a default feature? --- class: top, center # we believe in semver  --- class: top, left ## semver made easy # `npm version
` ### `types: major, minor, patch` - ### major: breaking changes - ### minor: feature add - ### patch: bug fix, docs --- class: top, left ### run scripts ### `npm test` ### `npm start` ### `npm run $anything` ### Automate CLI workflows, e.g. build steps, migrations  --- class: top, left ## lifecycle events ## `publish, install, uninstall, version, test, stop, start, restart` ## `pre, post`    --- class: top, left ## run scripts are composable #### `"db:migrate": "knex migrate:latest"` #### `"db:seed": "knex seed:run"` #### `"db:reset": "npm run db:migrate && npm run db:seed"`  --- 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: middle, center # npm private modules  -- ### (it's recursive! get it? get it?) -- npmnpmnpmnpmnpmnpmlolololololol --- class: top, left ## private modules ## `npm init --scope=
` ### Use your private modules side by side with modules from the public registry  --- class: middle, center # Managing access is hard...  --- class: top, left ## npm organizations # `npm team` - ### create teams and add members - ### grant and revoke access to packages via scopes  --- class: top, left # npm on-site ## run your own on-premises npm registry ### `npm login` ### ` --registry=http://reg.amazing.com`   -- (get it? run? runner?) --- class: middle, center  --- class: center, middle # thanks! ## `me => @ag_dubs` ## bit.ly/you-dont-know-npm   