npm_yarn
Overview
Both use a package.json to record packages
You can add scripts to your package.json and run them with both
Recommended is npm as it adopted many of yarn's features and has more commands like --force or --legacy-deps
Npm
Npx
npx makes it easy to use CLI tools and other executables hosted on the registry
Easy way to keep it updated
Yarn
Upgrading packages
Package.json Syntax
or example, to specify acceptable version ranges up to 1.0.4, use the following syntax:
Patch releases:
1.0
or1.0.x
or~1.0.4
Minor releases:
1
or1.x
or^1.0.4
Major releases:
*
orx
~1.0.2
= latest patch version like 1.0.4
^1.0.2
= latest minor/patch version like 1.1.0
.
Dev Dependencies
Things only used in dev like testing frameworks, bundling, or checking code style
if NODE_ENV
is set to production
npm will skip devDependencies
Last updated