Skip to content

Error on execution #2

@sebastienbarre

Description

@sebastienbarre

Thank you for making this tool available.
On macOS 26.1 (MacBook Pro M4), I'm getting errors after running:

$ npx git-rewrite-commits --max-commits 10 --api-key "..."

I abbreviated the path names below.
Note that I have no git/filter-msg.js, I assume you are trying to create that file?


🔄 Rewriting git history...
file://[ABBREVIATED]/monorepo/.git/filter-msg.js:2
const fs = require('fs');
           ^

ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '[ABBREVIATED]/monorepo/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
    at file://[ABBREVIATED]/monorepo/.git/filter-msg.js:2:12
    at ModuleJob.run (node:internal/modules/esm/module_job:377:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:691:26)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:101:5)

Node.js v24.11.0
msg filter failed: node [ABBREVIATED]/monorepo/.git/filter-msg.js

❌ Error rewriting history: Command failed: git filter-branch -f --msg-filter 'node [ABBREVIATED]/monorepo/.git/filter-msg.js' HEAD
Command failed: git filter-branch -f --msg-filter 'node [ABBREVIATED]/monorepo/.git/filter-msg.js' HEAD
file://[ABBREVIATED]/monorepo/.git/filter-msg.js:2
const fs = require('fs');
           ^

ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '[ABBREVIATED]/monorepo/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
    at file://[ABBREVIATED]/monorepo/.git/filter-msg.js:2:12
    at ModuleJob.run (node:internal/modules/esm/module_job:377:25)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions