Upon reaching this point, I found myself perplexed by the recommendations from Google. As of now (2023), npm is only capable of listing production dependencies using npm --omit=dev
(npm >=8). Unfortunately, there isn't an option to list only the dev
dependencies (no --omit=production/prod
), but you can achieve this in bash with a workaround like:
npm ls --depth=0 | awk -F' ' '{print $2}' | grep -vxF -f <(npm ls --omit=dev --depth=0 | awk -F' ' '{print $2}')
The purpose of the awk
part is to extract just the package names without the additional formatting provided by npm ls
.