TLDR; Compares your lockfile with installed dependencies and triggers an installation on mismatches. Works with npm, yarn and pnpm.
Tired of your local dev-server not starting after you checked out a branch that has different dependencies than you previous
one? Normally you would have to manually update your dependencies. sync-deps
can automate this step.
Based on your lockfile it automatically detects whether you use npm
, yarn
or pnpm
and acts accordingly.
heavily inspired by this gist!
Install as devDependency (adds ~1MB to your node_modules
): yarn add -D sync-deps
In this case sync-deps checks your dependencies before your dev server starts.
Example - in a NextJS environment:
{
"scripts": {
"predev": "sync-deps",
"dev": "next dev"
}
}
In this case sync-deps checks your dependencies, whenever you check out a different branch via git
.
with yarn:
yarn add -D husky
yarn husky install
yarn husky add .husky/post-checkout "sync-deps"
with npx:
npm install husky --save-dev
npx husky install
npx husky add .husky/post-checkout "sync-deps"