Packages
This is the general npm package list for JS, the individual folders have more specific packages for them, but this is the general ones that can be used anywhere.
To use core nodeJS modules you need some extra bundler configuration
Compare package trends with npmtrends
Package Managers
2024 Rec: pnpm for small projects, npm for large projects
2022 Rec: npm, as it adopted many of yarn's features and has more commands like --force or --legacy-deps
Choosing a Manager
npm vs pnpm vs yarn
All use a package.json, run scripts
Main diff is lockfiles: pnpm-lock.yaml, yarn.lock, package-lock.json
Trends show npm 4000x installs of pnpm, and 2024 pnpm gaining relative market share 5x in last 2 years vs 2x of others
Choose yarn for emojis!
confusing future versions
Pnpm
pnpm lock files use yaml are easier to diff/merge conflicts :)
very space efficient: pnpm use global node modules instead of installing per project, and only stores files that changed
faster install than rpm
Corepak manages package managers (Experimental)
uses new field in package.json "packageManager": "pnpm@8.15.8", avoids package manager problems by downloading and using specific version
Seems too weird, try using asdf instead
Pnpm
npm install
npm i <pkg>
npm run <cmd>
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
Fields
Just use the special pre and post prefix to run things before and after command
Last updated