
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
require-main-filename
Advanced tools
shim for require.main.filename() that works in as many environments as possible
require.main.filename
is great for figuring out the entry
point for the current application. This can be combined with a module like
pkg-conf to, as if by magic, load
top-level configuration.
Unfortunately, require.main.filename
sometimes fails when an application is
executed with an alternative process manager, e.g., iisnode.
require-main-filename
is a shim that addresses this problem.
var main = require('require-main-filename')()
// use main as an alternative to require.main.filename.
ISC
The find-root package is used to find the root directory of a Node.js project by traversing up the current directory until it finds a directory containing a package.json file. It is similar to require-main-filename in that it helps identify a key directory in a Node.js project, but it focuses on the project root rather than the main entry point file.
pkg-dir is another package that can be used to find the root directory of a Node.js project. It works similarly to find-root but uses a different implementation. It provides a promise-based API and can be used in modern async/await code styles. While it serves a similar purpose in identifying important project directories, it does not provide the filename of the main entry point like require-main-filename does.
app-root-path is designed to allow you to require modules from the root of your application without relying on relative paths. It is somewhat related to require-main-filename in that it deals with project structure and module resolution, but it does not specifically provide the main entry point filename. Instead, it focuses on simplifying the module requiring process from the application's root directory.
FAQs
shim for require.main.filename() that works in as many environments as possible
The npm package require-main-filename receives a total of 21,431,568 weekly downloads. As such, require-main-filename popularity was classified as popular.
We found that require-main-filename demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.