
Security News
New React Server Components Vulnerabilities: DoS and Source Code Exposure
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.
Maintenance notice: this package is no longer under active maintenance.
CLI to convert JavaScript files from CommonJS to ES6 / ES2015 modules format. The process isn't foolproof, but it can usually get you ~95% of the way there.
This tool uses jscodeshift to run 5to6-codemod and js-codemod under the hood. It attempts to convert require() and module.exports / exports to import and export.
npm i -g cjs-to-es6
cjs-to-es6 [ --verbose ] files/directories...
All files are modified in-place. You may want to review & rename them to the .mjs extension, if using Node 14 or later. Un-converted files should use the .cjs extension.
Examples:
cjs-to-es6 index.js # convert a single file
cjs-to-es6 lib/ # convert all files in a directory & its subdirectories (.js & .cjs)
cjs-to-es6 foo.js bar.js lib/ # convert many files/directories
FAQs
Convert JavaScript files from CommonJS to ES6 modules
We found that cjs-to-es6 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.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.