How to see the size of each node module in your Front End Project in Windows?
1 min readDec 22, 2023
Go to Powershell and go to your project directory.
Then run the below command.
Thiss command will sort it based on the size of the package.
# Get top-level folders
$topLevelFolders = Get-ChildItem -Directory
# Create an array to store folder information
$folderInfo = @()
# Loop through top-level folders
foreach ($folder in $topLevelFolders) {
$folderPath = $folder.FullName
$sizeInBytes = (Get-ChildItem -Recurse $folderPath | Measure-Object -Property Length -Sum).Sum
$sizeInKB = $sizeInBytes / 1KB
$sizeInMB = $sizeInBytes / 1MB
# Add folder information to the array
$folderInfo += [PSCustomObject]@{
Path = $folderPath
SizeInKB = $sizeInKB
SizeInMB = $sizeInMB
}
}
# Sort the array by folder size in descending order
$sortedFolders = $folderInfo | Sort-Object -Property SizeInKB -Descending
# Display the sorted list
foreach ($folder in $sortedFolders) {
Write-Host "$($folder.Path)`t$($folder.SizeInKB) KB ($($folder.SizeInMB) MB)"
}