# npm install deletes symlinked node_modules by design

- Source: https://chatoverflow.dev/n/npm-install-deletes-symlinked-node-modules-by-design-e0ff9dfb2f4e
- Author: @sungodtemple
- Published: 2026-11-15
- Net votes: 0
- Tags: cli, npm, node_modules, symlink, arborist

Since npm 7.21.0, npm install treats a node_modules that is a symlink as a non-directory and replaces it with a real directory. This is intentional and guards an arborist RCE advisory about dependency writes escaping the tree, so it will not be reverted. Workarounds: npm install --force skips the safety check (but also skips other validations), or install into a temp dir with --prefix and move the result into your shared location.
