Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 13

Understand

package.json better
Toluwalase Akintoye
Software Engineer, Cotta & Cush
Highlights
⬢ What is package.json?
⬢ package.json file structure
⬢ Semantic versioning

2
1 What is package.json?
It is a file that depicts the packages and javascript related information
for your project to run.
Creating a package.json
⬢ New project boilerplate
⬢ Command line

⬢ Manually

4
2 File Structure
There is no fixed requirements of what should be in package.json but
the content must be in json format.
Key specifics of package.json
⬢ version
⬢ name
⬢ description
⬢ main
⬢ private
⬢ scripts
⬢ dependencies
⬢ devDependencies
⬢ engines
⬢ browserlist

6
3 Semantic Versioning
Each installed package have different versions based on releases and
packages depends on other packages and they express those
dependencies via version ranges.
What package dependencies are all about
dependencies devDependencies peerDependencies
Packages your Packages your Expresses compatibility
application need to run in application need to run in between packages that
production. local development and depend on different
testing. versions of a package

8
Peer Dependencies

More than one package


can depend on different
versions of another
package

9
Semantic Versioning: Releases
X . Y . Z => 1.2.3

Z Patch Version
Number increases when there are
backward-compatible bug fixes

Major Version
Number increases when there is an
incompatible API changes

x Y
Minor Version
Number increases when there is a
backward-compatible functionality

10
Semantic Versioning: Symbol Rules
Updates does not affect Updates package to any Updates package to any
the leftmost zero i.e higher version than the version lower than the Updates package to the Updates package to
from 1.0.0 to 1.0.1 or specified version i.e specified version i.e exact version i.e =1.2.0 combine sets 1.0.0 || Updates package to any
1.1.0 but not to 2.0.0 from >1.0.0 to 2.0.0 <1.5.0 to 1.4.1 to 1.2.0 >=1.1.0 <1.2.0 version

> <
^ ~ > < = = - || latest
*
=
Updates only affects Updates package to any Updates package to any Updates package to the
Updates package to the
the patch version i.e specified or higher specified or lower version ranges i.e 1.0.0-
latest version
1.0.0 to 1.0.1 only version i.e >=1.0.2 to version i.e <=1.5.0 to 1.2.0
1.5.0 1.4.9

11
THANKS!
Any questions?

12
CREDITS
⬢ Package.json guide
⬢ Understanding npm dependency model
⬢ Semantic Versioning
⬢ Presentation template by SlidesCarnival

13

You might also like