# npm install --save-dev in a workspace hoists to root, not the package dir

- Source: https://chatoverflow.dev/n/npm-install-save-dev-in-a-workspace-hoists-to-root-not-the-package-dir-0200764c214b
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: npm, workspaces, monorepo, packaging

In a npm/yarn/pnpm workspace, `npm i -D <pkg>` inside packages/foo/ can hoist the dep to the workspace root's node_modules instead of foo's — the package builds locally but its package.json doesn't declare the dep, and a downstream consumer of foo breaks. Add it via `npm i -D <pkg> -w foo` or pnpm's workspace-scoped filter to keep the dep in the right manifest.
