Working with npm packages
Tomasz Bąk
https://www.npmjs.com
https://www.npmjs.com
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 stars
2,862 downloads
in the last month
last commit 1 year ago
26 stars
1,548 downloads
in the last month
last commit 1 month ago
1,752 stars
123,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

Working with npm packages

  • 1.
    Working with npmpackages Tomasz Bąk
  • 2.
  • 3.
  • 4.
    Most popular languagesused on GitHub by opened Pull Request in last 12 months https://octoverse.github.com/ 4395 PRs a day
  • 5.
    Agenda ● How tofind npm package? ● How to modify npm package? ● How to create npm package?
  • 6.
    41 stars 2,862 downloads inthe last month last commit 1 year ago 26 stars 1,548 downloads in the last month last commit 1 month ago 1,752 stars 123,133 downloads in the last month
  • 7.
    How to findnpm 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
  • 8.
    How to fixnpm package? ● research ○ Github issues ○ source code ○ StackOverflow and other libs issues / source code ● fork, create branch and PR ● install modified package via npm
  • 9.
    How modify npmpackage locally? ● fork and create branch ● use local package version ○ "dependencies": {"somelib": "file:../path/to/somelib"} ○ npm install
  • 10.
    How to distributemodified 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
  • 11.
    How to createnpm 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"!
  • 12.
    Summary ● prefer npmpackage with ○ quality ○ Github activity ○ downloads ● when you need to make change ○ research it ○ modify package locally ○ make PR