Skip to content
This repository was archived by the owner on Jan 29, 2026. It is now read-only.

Commit 4a067ac

Browse files
Copilotclduab11
andauthored
Document ES module postinstall fix and add file extension guidelines (#71)
* Initial plan * Initial investigation: postinstall.cjs already exists and is properly configured Co-authored-by: clduab11 <185000089+clduab11@users.noreply.github.com> * Document ES module file extension guidelines in scripts/README.md Co-authored-by: clduab11 <185000089+clduab11@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: clduab11 <185000089+clduab11@users.noreply.github.com>
1 parent 81c59df commit 4a067ac

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

scripts/README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
# Scripts Directory
22

3+
## File Extension Guidelines
4+
5+
This project uses `"type": "module"` in package.json, making ES modules the default. To avoid ambiguity:
6+
7+
- **`.mjs`**: ES modules (use `import`/`export`)
8+
- **`.cjs`**: CommonJS modules (use `require()`/`module.exports`)
9+
- **`.js`**: Avoid in scripts directory (ambiguous with "type": "module")
10+
311
## postinstall.cjs
412

513
**Purpose**: Conditional Husky installation script
614

7-
**Problem Solved**: Fixes npm error 127 that occurs during global installs when husky (a devDependency) is not available.
15+
**Problem Solved**: Fixes npm error 127 that occurs during global installs when husky (a devDependency) is not available. Also prevents "ReferenceError: require is not defined in ES module scope" by using the `.cjs` extension for CommonJS code.
816

917
**How it works**:
1018
- Detects production, global, or CI environments

0 commit comments

Comments
 (0)