npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

npm install deletes almost all my code

What I Wanted to Do

with package-lock.json exists, npm may provide an option or so no to delete the symlinked dirs

What Happened Instead


Reproduction Steps

npm install (which will create package-lock.json)
cd node_modules/
ln -sf … @project (for getting rid of …/…/…/ hells)
cd …/
npm install (delete many files in the project root)


although package-lock=false in .npmrc will workaround this issue, I wonder if there is an option to disable this behavior(auto-prune symlink-ed dirs) or at least not those begin with @ or some special char?

Platform Info

npm --versions { npm: '6.11.3', ares: '1.15.0', brotli: '1.0.7', cldr: '35.1', http_parser: '2.8.0', icu: '64.2', llhttp: '1.1.4', modules: '72', napi: '5', nghttp2: '1.39.2', node: '12.11.0', openssl: '1.1.1c', tz: '2019a', unicode: '12.1', uv: '1.32.0', v8: '', zlib: '1.2.11' } node -p process.platform