Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@pnpm/read-modules-dir
Advanced tools
@pnpm/read-modules-dir is an npm package that allows you to read the contents of the node_modules directory. It provides a simple API to list all the packages installed in a node_modules directory, which can be useful for various tasks such as auditing dependencies, generating reports, or performing custom operations on installed packages.
List all packages in node_modules
This feature allows you to list all the packages in a specified node_modules directory. The code sample demonstrates how to use the package to read the contents of the node_modules directory and log the list of packages to the console.
const readModulesDir = require('@pnpm/read-modules-dir');
async function listPackages() {
const packages = await readModulesDir('path/to/node_modules');
console.log(packages);
}
listPackages();
Handle scoped packages
This feature allows you to handle scoped packages specifically. The code sample demonstrates how to filter and list only the scoped packages from the node_modules directory.
const readModulesDir = require('@pnpm/read-modules-dir');
async function listScopedPackages() {
const packages = await readModulesDir('path/to/node_modules');
const scopedPackages = packages.filter(pkg => pkg.startsWith('@'));
console.log(scopedPackages);
}
listScopedPackages();
The 'read-installed' package reads the installed packages in a node_modules directory and returns a tree structure of the dependencies. It provides more detailed information about each package, including version, dependencies, and more. Compared to @pnpm/read-modules-dir, 'read-installed' offers a more comprehensive view of the installed packages but may be more complex to use.
The 'npm-ls' package is a command-line tool that lists all the installed packages in a node_modules directory, similar to the 'npm ls' command. It provides a hierarchical view of the dependencies. Compared to @pnpm/read-modules-dir, 'npm-ls' is more focused on providing a command-line interface and may not be as easily integrated into custom scripts.
Finds all direct packages in node_modules
FAQs
Finds all direct packages in node_modules
The npm package @pnpm/read-modules-dir receives a total of 231,094 weekly downloads. As such, @pnpm/read-modules-dir popularity was classified as popular.
We found that @pnpm/read-modules-dir demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.