
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
analyze-require-default
Advanced tools
Analyze require()
statements of ES modules without .default
.
JavaScript's module systems can be confusing sometimes, specifically the tiny differences in default exports/imports between ES modules (import
/export
) and commonjs (module.exports
/require
) syntax.
Such differences can be hard to find manually, and could potentially cause weird behaviours/bugs, and this is what this package is for!
Here's a quick example to demonstrate:
// a.js
module.exports = 1;
// b.js
export default 2;
// Import default from
import a from 'a'; // This is fine, even though we're mixing 2 different module systems
import b from 'b'; // This is fine, we're on the same module system
const a = require('a'); // This is fine, we're on the same module system
const b = require('b'); // This is NOT fine, we'll get "{ default: 2 }"
Install the package:
npm i -g analyze-require-default
analyze-require-default [root] [options]
analyze-require-default ./app
Option | Alias | What it does | Positional arguments | Default |
---|---|---|---|---|
-c | --config | Uses a configuration file. | An absolute or relative path to a configuration file. | - |
-d | --debug | Outputs extra debugging information. | - | false |
-v | --version | Outputs the current version. | - | - |
-h | --help | Output the program's usage information. | - | - |
Can be either a .js
file or a .json
file, supports the following options:
Option | What it does | Type |
---|---|---|
root | An absolute or relative path to the root directory. | string |
alias | A map of path aliases, similar to Webpack's alias | Record<string, string | string[]> |
debug | Output extra debugging information. | boolean |
analyze-require-default -c ./config.js
// ./config.js
const path = require('path');
module.exports = {
root: './app',
debug: true,
alias: {
Utilities: path.resolve(__dirname, 'src/utilities/'),
Templates: path.resolve(__dirname, 'src/templates/'),
},
};
FAQs
Analyze require statements of ES modules without .default
The npm package analyze-require-default receives a total of 0 weekly downloads. As such, analyze-require-default popularity was classified as not popular.
We found that analyze-require-default 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.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.