working with npm packages
TRANSCRIPT
Working with npm packagesTomasz Bąk
Most popular languages used on GitHub by opened Pull Request in last 12 months https://octoverse.github.com/
4395 PRs a day
Agenda
● How to find npm package?
● How to modify npm package?
● How to create npm package?
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
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
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
How modify npm package locally?
● fork and create branch
● use local package version○ "dependencies": {"somelib": "file:../path/to/somelib"}
○ npm install
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
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"!
Summary
● prefer npm package with○ quality
○ Github activity
○ downloads
● when you need to make change○ research it
○ modify package locally
○ make PR