[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"howto:cjs:android:en":3},{"resolvedFromAlias":4,"canonicalExt":5,"ext":5,"name":6,"category":7,"categoryName":8,"updatedAt":9,"os":10,"osLabel":11,"quickSolution":12,"stepByStep":13,"recommendedSoftware":15,"alternativeMethods":16,"commonIssues":17,"securityNote":36,"extensionPath":37,"extensionLabel":38,"breadcrumbs":39,"metaDescription":49},false,"cjs","CommonJS Module File","code","Code","2026-06-12T08:01:45.984Z","android","Android","To open .CJS files on Android, if you only need to read it, open it in a plain-text/code viewer; to execute it you’ll typically need to transfer it to a desktop/server with Node.js.",[14],"If you only need to read it, open it in a plain-text/code viewer; to execute it you’ll typically need to transfer it to a desktop/server with Node.js.",[],[],[18,24,30],{"title":19,"description":20,"steps":21},"Node.js runs it as CommonJS when you expected ESM","In Node.js, .cjs is always CommonJS, even if your package.json sets \"type\": \"module\" and your other .js files behave as ESM.",[22,23],"If you want ESM semantics (import/export), rename the file to .mjs or .js (and ensure your package configuration matches).","If you need CommonJS, keep .cjs and use require/module.exports rather than import/export.",{"title":25,"description":26,"steps":27},"Syntax error: using import/export in a .cjs file","Because .cjs is forced to CommonJS in Node.js, ESM-only syntax can fail depending on how it is executed and what syntax is used.",[28,29],"Replace import/export with require() and module.exports/exports for CommonJS.","If the file must use ESM, switch to .mjs (or adjust your package setup so .js is ESM) and update imports accordingly.",{"title":31,"description":32,"steps":33},"A tool expects .js and does not recognize .cjs","Some workflows and scripts are hard-coded to look for .js and won’t pick up .cjs automatically.",[34,35],"Check the tool’s configuration for an option to specify the entry file explicitly and point it to the .cjs path.","If the tool cannot be configured, consider keeping a small .js wrapper that loads the .cjs module (or renaming if compatible).",".cjs files contain executable JavaScript; running an untrusted .cjs file with Node.js can execute arbitrary code with your user permissions.","/file-extension/cjs",".CJS",[40,43,46],{"label":41,"to":42},"Home","/",{"label":44,"to":45},"How To","/file-extension",{"label":47,"to":48},"Open .CJS on Android","/how-to/open-cjs-on-android","Learn how to open .CJS files on Android with step-by-step instructions, recommended software, and troubleshooting tips."]