Skip to content
Latchkey

yarn remove: Usage & Common Errors

Uninstall a dependency and update the manifest.

yarn remove uninstalls one or more packages, removing them from package.json and updating yarn.lock and node_modules.

What it does

Deletes the named packages from the appropriate dependency field, re-resolves the graph, and rewrites yarn.lock. It only operates on direct dependencies declared in package.json, not transitive ones.

Common usage

Terminal
yarn remove lodash          # remove one package
yarn remove jest @types/jest # remove several at once

Common error: not specified in package.json

yarn remove fails with "This module isn’t specified in a package.json file" (Yarn 1) or a similar Berry error. You are trying to remove a transitive dependency or a misspelled name. Only direct deps can be removed - check package.json for the exact key first.

Terminal
# confirm it is a direct dependency before removing:
yarn why some-pkg

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →