← Back to Desktop app developers
See how it helps
2. ESM / CJS Interop &
3. TypeScript &
JavaScript package upgrades
Updates npm, pnpm or Yarn dependencies while respecting the repository's manager, module formats and type contracts.
npm-pnpm-yarn-upgrades
Team members using this skill
When is it useful?
Use when an upgrade changes exports, ESM compatibility or TypeScript requirements.
What does it help you do?
- Preserves package-manager version and lockfile format.
- Checks ESM/CommonJS resolution and public export conditions.
- Coordinates types, scoped overrides and installation scripts.
Try asking this
Upgrade a library that moved to ESM and verify both production bundling and the existing test runner. Test importing the upgraded package from both application and test configuration. Preserve frozen installation and explain any required ESM boundary adjustment.
Detailed documentation
Read the skill’s original instructions, examples and checks in their authored language.
Show less
npm, pnpm & Yarn Upgrades
When to Use
Use when upgrading Node.js, frontend, or full-stack JavaScript/TypeScript packages managed by npm, pnpm, yarn (v1 or Berry v3/v4), or bun.
Package Manager Mechanics & Discipline
1. Respect Corepack & Lockfile Format
- Check root
package.json"packageManager"(e.g.,"pnpm@9.12.0","yarn@4.5.0") and.npmrc/.yarnrc.yml. - Use only the repository's active package manager:
- npm:
npm install <pkg>@<version>updatespackage.jsonandpackage-lock.json. Usenpm dedupewhen transitive trees fragment after an update. Never use--legacy-peer-depsor--forcewithout proving the peer mismatch is benign at runtime. - pnpm: Strict node_modules layout prevents phantom dependencies (importing undeclared transitive packages). Use
pnpm up <pkg>@<version>(or-racross workspaces). If an upgraded package fails because it relied on hoisted undeclared dependencies, fix the manifest or use.pnpmfile.cjs/packageExtensionsrather thanshamefully-hoist=true. - Yarn Berry (v2–v4): Inspect
.yarnrc.yml(nodeLinker: pnp | pnpm | node-modules). With Plug'n'Play (pnp), undeclared peer dependencies throwYN0002/ERR_PNPM_PEER_DEP_ISSUES; declare missing peers viapackageExtensionsin.yarnrc.ymland runyarn dedupe.
- npm:
2. ESM / CJS Interop & exports Map Transitions
Many modern JS packages drop CommonJS (require()) in major upgrades (e.g., chalk, execa, nanoid, ora, file-type, unified, Rehype/Remark ecosystem):
- Inspect the target package's
package.jsonfor"type": "module"and"exports"conditions (import,require,types,default,node,browser). - If the consuming project compiles to CommonJS (
"module": "CommonJS"intsconfig.jsonor no"type": "module"), upgrading to an ESM-only package will fail at runtime withERR_REQUIRE_ESMunless:- The project or build target is migrated to ESM (
"type": "module","moduleResolution": "NodeNext" | "Bundler"), or - The package is bundled by Vite/esbuild/Webpack (
ssr.noExternal/transpilePackages), or - You stay on the maintained CJS-compatible major line (and document why).
- The project or build target is migrated to ESM (
- Never replace a static
importwith an untestedawait import()inside synchronous hot paths just to silenceERR_REQUIRE_ESM.
3. TypeScript & @types/* Alignment
- Check whether the upgraded package now bundles its own
.d.tsdeclarations ("types"or"typings"in itspackage.json). If so, remove the obsolete@types/<pkg>devDependency so staleDefinitelyTyped definitions do not shadow the official types. - Keep
@types/nodealigned with the project's actual target Node.js LTS major (engines.node,.nvmrc,Dockerfile), not a newer Node major that introduces globals unavailable in production. - When upgrading
typescriptitself, checkmoduleResolution, stricter generic inference,verbatimModuleSyntax, and framework typecheckers (vue-tsc,@angular/compiler-cli,astro check,svelte-check).
4. Scoped Overrides, Resolutions & Lifecycle Scripts
- When pinning a transitive dependency:
- npm:
"overrides": { "parent-pkg": { "vulnerable-child": "1.2.3" } }(prefer scoped overrides over global overrides whenever possible). - pnpm:
"pnpm": { "overrides": { "parent-pkg>vulnerable-child": "1.2.3" } }. - Yarn:
"resolutions": { "parent-pkg/vulnerable-child": "1.2.3" }.
- npm:
- Check
.npmrcforignore-scripts. When upgrading packages with lifecycle scripts (esbuild,sharp,playwright,cypress,lefthook,husky), verify postinstall binary resolution across local dev and CI.
Included files 1
SKILL.md
