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.
is-builtin-module
Advanced tools
The is-builtin-module npm package is used to check if a given module name corresponds to a Node.js built-in module. This can be useful when developing tools that need to differentiate between built-in modules and third-party modules, such as bundlers, linters, or dependency analysis tools.
Check if a module is a built-in module
This feature allows you to check if a given string corresponds to a Node.js built-in module. In the code sample, 'fs' is recognized as a built-in module, while 'express' is not.
const isBuiltinModule = require('is-builtin-module');
console.log(isBuiltinModule('fs')); // true
console.log(isBuiltinModule('express')); // false
The 'builtin-modules' package provides a list of the built-in modules of Node.js. It is similar to 'is-builtin-module' but instead of checking if a module is built-in, it provides the full list of built-in modules. You can use this list to check for built-in modules manually.
The 'resolve' package is a module resolution algorithm for Node.js, similar to the one used by 'require'. It can be used to check if a module is resolvable and, by extension, to infer if it is a built-in module. However, it is more general-purpose and not specifically designed for checking built-in modules.
Check if a string matches the name of a Node.js builtin module
Note that this matches based a static list of modules from the latest Node.js version. If you want to check for a module in the current Node.js, use the core isBuiltin
method.
npm install is-builtin-module
import isBuiltinModule from 'is-builtin-module';
isBuiltinModule('fs');
//=> true
isBuiltinModule('fs/promises');
//=> true
isBuiltinModule('node:fs/promises');
//=> true
isBuiltinModule('unicorn');
//=> false
FAQs
Check if a string matches the name of a Node.js builtin module
The npm package is-builtin-module receives a total of 5,067,835 weekly downloads. As such, is-builtin-module popularity was classified as popular.
We found that is-builtin-module demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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.