When you edit files inside node_modules, Git does not track them
--- so git status won't help detect changes.
This guide explains how to use sha1sum (or md5sum) to detect
modified packages.
Ensure that sha1sum is available in your system (run this in bash,
not PowerShell):
$ sha1sum --help
Usage: sha1sum [OPTION]... [FILE]...
Print or check SHA1 (160-bit) checksums.If you see similar output, the command is ready to use.
find node_modules -type f -name "*.js" | sort | xargs sha1sum > .node_modules.hashfind node_modules -type f | sort | xargs sha1sum > .node_modules.hashTo skip .png, .jpg, .jar, and .aar files:
find node_modules -type f ! -name "*.png" ! -name "*.jpg" ! -name "*.jar" ! -name "*.aar" | sort | xargs sha1sum > .node_modules.hashfind node_modules -type f -name "*.js" | sort | xargs md5sum > .node_modules.hashEach line includes the hash and file path:
116d3be5fc68bb1840a26330c47bd986508c7e5b *node_modules/@twotalltotems/react-native-otp-input/index.js
After editing and saving files inside node_modules, run:
sha1sum -c .node_modules.hash | grep FAILED | awk -F'[:/]' '{print $1} {print $2} {print $3}' | sort -uExample output:
sha1sum: WARNING: 1 computed checksum did NOT match
@twotalltotems
node_modules
react-native-otp-input
This output indicates which package(s) need to be patched.
Once you've identified the modified package, create a patch using:
yarn patch-package✅ Done!
You can now track which packages have been manually edited and safely
generate patch files.