You can do it with the following bash script started from your project folder. For ease of understandability it calls node for each matching package.json. To improve performance you can replace the multiple here documents by a single one (arround the for loop) and call node once.
#!/bin/bash
for d in $(find node_modules -name package.json \
-exec grep -lw peerDependencies {} \;)
do
node << EOF
const {peerDependencies } = require('./$d');
for (k in peerDependencies) {
console.log('File $d:', k, peerDependencies[k]);
}
EOF
done
And here the more performant version:
#!/bin/bash
for d in $(find node_modules -name package.json \
-exec grep -lw peerDependencies {} \;)
do
echo "m = require('./$d');
for (k in m.peerDependencies) {
console.log('File $d:', k, m.peerDependencies[k]);
}"
done |
node