Registry / type-stubs / common-js-file-extensions

common-js-file-extensions

JSON →
library1.0.4jsnpmunverified

The `common-js-file-extensions` package provides two static arrays, `code` and `config`, listing various file extensions associated with JavaScript code and configuration files, respectively. It includes extensions for a wide range of JavaScript dialects and transpiled languages, such as standard `.js`, `.mjs`, `.cjs`, as well as older or less common ones like `.coffee`, `.ts`, `.iced`, `.es6`, `.jsx`, and `.json5`. Currently at version 1.0.4, the package appears to be stable but likely no longer actively maintained, given its last update years ago (copyright 2016). Its primary utility lies in offering a comprehensive, if somewhat dated, reference for tools needing to identify JavaScript-related files without needing to parse package manifests or project configurations for specific language tooling.

npm install common-js-file-extensions
INSTALL
IMPORT
SIG · COMMON-JS-FILE-EXT
C
common-js-file-extensions
type-stubsjavascriptv1.0.4
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

code, config
const { code, config } = require('common-js-file-extensions');
import { code, config } from 'common-js-file-extensions';
This package is a CommonJS module. For ES Modules, import the default object and destructure it.
All exports as default
import extensions from 'common-js-file-extensions'; const { code, config } = extensions;
import * as extensions from 'common-js-file-extensions';
When importing a CommonJS module into an ES Module context, the module's exports object becomes the default export. Using `import * as` might work in some bundlers but is not the standard Node.js behavior.

Demonstrates how to import the `code` and `config` arrays and iterate through the listed extensions. It also includes a basic example of checking a file's extension against these lists.

const { code, config } = require('common-js-file-extensions'); console.log('--- JavaScript Code File Extensions ---'); code.forEach(ext => console.log(` .${ext}`)); console.log('\n--- JavaScript Config/Object File Extensions ---'); config.forEach(ext => console.log(` .${ext}`)); // Example of checking a file extension const fileName = 'my-component.tsx'; const fileExtension = fileName.split('.').pop(); if (fileExtension && code.includes(fileExtension)) { console.log(`\n'${fileName}' is a known JavaScript code file.`); } else if (fileExtension && config.includes(fileExtension)) { console.log(`\n'${fileName}' is a known JavaScript config/object file.`); } else { console.log(`\n'${fileName}' is not recognized as a common JS file type.`); }
Debug
Known issues
gotchaThis package is explicitly a CommonJS module. While it can be imported into an ES Module (ESM) context, direct named imports (`import { code } from 'pkg'`) will not work as expected in Node.js, often resulting in `undefined` or runtime errors. ESM users must import the module's default export (which is the CommonJS `module.exports` object) and destructure from that.
fix
For ES Modules, use `import extensions from 'common-js-file-extensions'; const { code, config } = extensions;`. For CommonJS, `const { code, config } = require('common-js-file-extensions');` is correct.
affects: >=1.0.0
gotchaThe package includes a very comprehensive list of extensions, encompassing many older, niche, or less common JavaScript dialects and transpilers (e.g., IcedCoffeeScript, Stratified JavaScript, LiveScript, Earl Grey). While thorough, this breadth might not be relevant for most modern JavaScript projects and could lead to over-inclusive file scanning or unnecessary complexity if used without filtering.
fix
Developers should filter or curate the `code` and `config` arrays to include only the extensions relevant to their specific project or environment if broad inclusion is not desired.
affects: >=1.0.0
deprecatedThe package has not seen updates since its initial releases around 2016 (indicated by copyright and versioning). This suggests it is no longer actively maintained. While its static data is unlikely to 'break', new or evolving JavaScript file extensions (e.g., future TypeScript or JSX variants, or new bundler-specific extensions) will not be added.
fix
For applications requiring an up-to-date list of JavaScript file extensions, consider manually curating a list or finding a more actively maintained library, though for its specific historical data, this package remains functional.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Cannot destructure property 'code' of 'common_js_file_extensions_1' as it is undefined.
Attempting a named ES Module import (`import { code } from 'common-js-file-extensions';`) of a CommonJS module in a Node.js ESM environment.
fix
Import the module's default export first, then destructure from it: `import extensions from 'common-js-file-extensions'; const { code, config } = extensions;`
ReferenceError: require is not defined
Attempting to use `require()` syntax in an ES Module (ESM) file without proper transpilation or configuration.
fix
If your project is ESM-first, use `import` syntax: `import extensions from 'common-js-file-extensions'; const { code, config } = extensions;`. If you must use `require` in an ESM file, you might need to use `createRequire` from the `module` built-in module, but it's generally recommended to stick to `import`.
Upgrade
Version history
1.0.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
51 hits · last 30 days
node
46
OpenAI (training)
1
Resources
common-js-file-extensions — npm install common-js-file-extensions · libregistry