Ls List / Print Tree Of Locally Installed Modules
Print Tree Of Locally Installed Modules
Displays a tree structure of locally installed packages in the project.
pnpm ls pnpm ls #!/bin/bash
# Print Tree Of Locally Installed Modules
pnpm {{[ls|list]}} import subprocess
# Print Tree Of Locally Installed Modules
# Make sure to replace <placeholders> with actual values
def run_command():
cmd = [
"ls-list",
"ls"
]
try:
print(f"Executing: {' '.join(cmd)}")
subprocess.run(cmd, check=True)
except subprocess.CalledProcessError as e:
print(f"Error: {e}")
except FileNotFoundError:
print("Error: ls-list not found. Please install it first.")
if __name__ == "__main__":
run_command() When To Use
When verifying installed packages after dependency updates or installs.
Pro Tip
Use `--long` for detailed output including version numbers and dependency paths.
Anatomy of Output
Understanding the result
example-package@1.0.0 Top Level Package Indicates a direct dependency installed.
└── dependency1@2.0.0 Dependency Shows a nested dependency of the top level package.
└── dependency2@3.0.0 Dependency Another nested dependency.
Troubleshooting
Common pitfalls
ERR_PNPM_NO_PACKAGE_FOUND: No packages found in project
Solution: Check if you are in the correct directory that contains the package.json.
ERR_PNPM_TREE_BUILD_FAILED: Failed to build the package tree
Solution: Ensure all dependencies are installed properly before listing.
ERR_PNPM_INVALID_OUTPUT: Unexpected error printing package tree
Solution: Check for permission issues preventing visibility of node_modules.
Command Breakdown
What each part is doing
-
pnpm - Base Command
- The executable that performs this operation. Here it runs Ls List before the shell applies any redirect operators.
-
ls - ls|list
- The value supplied for ls|list.
Alternative Approaches
Comparable commands in other tools
Alternative package management tools for the same job.