npm "Tracker idealTree already exists" - Fix Concurrent Install Error
npm builds an in-memory "idealTree" while installing and guards it so only one install runs at a time. This error means a second npm started while another was still going, or a previous one died without cleaning up.
What this error means
An install fails almost immediately with "Tracker "idealTree" already exists". It often shows up when a build script kicks off two installs in parallel, or after a cancelled job left npm in a bad state.
npm error Tracker "idealTree" already exists
npm error A complete log of this run can be found in: .../_logs/...-debug-0.logCommon causes
Two npm installs running concurrently
Parallel CI steps, a Makefile target, or a postinstall hook that itself runs npm install can start a second install while the first holds the tree, triggering the guard.
A leftover lock from a killed install
If a prior install was cancelled or OOM-killed, a stale _cacache/lock state in ~/.npm can make the next npm think a tree is already in progress.
How to fix it
Serialize installs and clear stale state
Ensure only one install runs, then clear the npm cache locks before retrying.
# make sure nothing else runs npm at the same time
rm -rf node_modules
npm cache clean --force
npm ciRemove the concurrency
- Audit postinstall/prepare scripts for nested
npm installcalls. - In CI, do not run two install steps for the same project in parallel.
- If a matrix shares a cache dir, give each leg its own npm cache (
--cache).
How to prevent it
- Run exactly one install per project, sequentially.
- Avoid lifecycle scripts that re-invoke npm install.
- Give parallel jobs isolated npm cache directories.