copy-node-modules icon indicating copy to clipboard operation
copy-node-modules copied to clipboard

Deeply nested dependencies are not copied

Open mpsijm opened this issue 2 years ago • 1 comments

To reproduce:

~ $ mkdir tmp
~ $ cd tmp
~/tmp $ npm i --save [email protected]
~/tmp $ npm i --save-dev copy-node-modules
~/tmp $ npm ls @mongodb-js/saslprep
tmp@ /home/mpsijm/tmp
└─┬ [email protected]
  └─┬ [email protected]
    └── @mongodb-js/[email protected] deduped

~/tmp $ mkdir dist
~/tmp $ npx copy-node-modules . dist
~/tmp $ cd dist
~/tmp/dist $ npm ls @mongodb-js/saslprep
/home/mpsijm/tmp/dist
└── (empty)

In this example, the nested dependency @mongodb-js/saslprep should be copied to dist/node_modules (as dependency of mongodb, but it's not. Note that mongodb itself is copied, even though its dependencies are not:

~/tmp/dist $ npm ls mongodb
/home/mpsijm/tmp/dist
├── [email protected] extraneous
└─┬ [email protected] extraneous
  └── [email protected] deduped

This is probably because mongodb exists at the top-level node_modules folder, whereas @mongodb-js/saslprep does not.

System info:

  • Arch Linux
  • Node v18.18.0
  • NPM v10.2.1

mpsijm avatar Nov 06 '23 10:11 mpsijm

As a workaround, it is also possible to copy the entire repository, run npm i --omit dev, and then copy the resulting node_modules folder.

mpsijm avatar Nov 06 '23 10:11 mpsijm