working with npm packages

12

Click here to load reader

Upload: tomasz-bak

Post on 13-Apr-2017

247 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Working with npm packages

Working with npm packagesTomasz Bąk

Page 2: Working with npm packages

https://www.npmjs.com

Page 3: Working with npm packages

https://www.npmjs.com

Page 4: Working with npm packages

Most popular languages used on GitHub by opened Pull Request in last 12 months https://octoverse.github.com/

4395 PRs a day

Page 5: Working with npm packages

Agenda

● How to find npm package?

● How to modify npm package?

● How to create npm package?

Page 6: Working with npm packages

41 stars2,862 downloadsin the last monthlast commit 1 year ago26 stars1,548 downloadsin the last monthlast commit 1 month ago

1,752 stars123,133 downloads in the last month

Page 7: Working with npm packages

How to find npm package?

● Google, github.com, npmjs.com○ always check github activity and code quality

○ Downloads (npmjs.com) > Github stars > search result position

● github activity○ commits, issues, pull requests

● quality○ documentation, demo page, code, tests

Page 8: Working with npm packages

How to fix npm package?

● research○ Github issues

○ source code

○ StackOverflow and other libs issues / source code

● fork, create branch and PR

● install modified package via npm

Page 9: Working with npm packages

How modify npm package locally?

● fork and create branch

● use local package version○ "dependencies": {"somelib": "file:../path/to/somelib"}

○ npm install

Page 10: Working with npm packages

How to distribute modified package?

● npm install --save github-user/somelib#my-fix-branch○ more at https://docs.npmjs.com/files/package.json#dependencies

○ will not work if dist/ code is .gitignored

● npm install --save github-user-somelib-my-fix○ change “name” to github-user-somelib-my-fix

○ npm build

○ npm publish

Page 11: Working with npm packages

How to create npm package?

● npm init○ "name": "somelib"○ "main": "index.js"

● add○ README.md○ "repository" : { "type" : "git", "url" : "https://github.com/me/somelib.git"}○ "scripts" : { "test": ... }○ more at https://docs.npmjs.com/files/package.json

● npm publish○ bump "version": "0.0.2"!

Page 12: Working with npm packages

Summary

● prefer npm package with○ quality

○ Github activity

○ downloads

● when you need to make change○ research it

○ modify package locally

○ make PR