Regex for VS Code and IDE Search/Find CommonJS require calls

Find CommonJS imports for migration to ESM.

Section: Editor Refactor Recipes

Find CommonJS require calls

regex
regex
\bconst\s+([A-Za-z_$][\w$]*)\s*=\s*require\((['"][^'"]+['"])\)
Explanation

Useful when converting Node projects to ESM.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Editor Refactor Recipes
Find simple `var` declarations
Find `var` declarations for modernization review.
OpenIn sheetregexsame section
Find 3+ blank lines
Reduce excessive blank vertical spacing.
OpenIn sheetregexsame section
Find repeated spaces
Match runs of multiple spaces.
OpenIn sheetregexsame section
Capture ES import path
Find JavaScript/TypeScript imports and capture the module path.
OpenIn sheetregex1 tag match
Enable regex mode in search
Use regex search in VS Code find/replace.
Add commas to object properties
Find non-final object property lines missing a comma.