Skip to content

modules: add guide for migrating from module.register() - #190

Open
GeoffreyBooth wants to merge 2 commits into
nodejs:mainfrom
GeoffreyBooth:migrate-module-register
Open

GeoffreyBooth wants to merge 2 commits into
nodejs:mainfrom
GeoffreyBooth:migrate-module-register

Conversation

@GeoffreyBooth

Copy link
Copy Markdown
Member

Node.js 27 removes module.register() and the --experimental-loader/--loader flags (DEP0205); the removal is in nodejs/node#67090. A reviewer there asked for a landing page explaining the migration before 27.0.0 ships, and this is it.

The page covers:

  • Choosing between rewriting hooks for module.registerHooks(), using module-register-ponyfill, or building a bridge with everysync
  • Before/after rewrite of a resolve/load hooks module, and replacing --loader with --import
  • Behavior differences: hooks run on the main thread (no initialize/data), can't be async, now apply to require(), and aren't inherited by workers
  • Hooks that need asynchronous work, with a working everysync example
  • Troubleshooting with the exact error messages

It is linked from the "Modules" group in site.json. I ran every code example against a Node.js build with register() removed.

🤖 Generated with Claude Code

Node.js 27 removes `module.register()` and the `--experimental-loader`
and `--loader` flags (DEP0205). Explain how to move to
`module.registerHooks()`, what behaves differently, and what to use when
hooks need asynchronous work (`module-register-ponyfill` or `everysync`).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@GeoffreyBooth
GeoffreyBooth requested a review from a team as a code owner November 9, 2026 15:55
Copilot AI balanced review requested due to automatic review settings November 9, 2026 15:55
@vercel

vercel Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
nodejs-learn Ready Ready Preview Nov 9, 2026 11:54pm UTC

Request Review

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

👋 Codeowner Review Request

The following codeowners have been identified for the changed files:

Team reviewers: @nodejs/loaders @nodejs/nodejs-website

Please review the changes when you have a chance. Thank you! 🙏

@avivkeller

avivkeller commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Should this be a learn article or a blog cc @nodejs/nodejs-website

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The migration guide overstates registration-chain compatibility and omits an explicit network-appropriate timeout, so valid hook bootstrapping or module downloads can fail.

2 open issues
What changed in this PR

Adds a migration guide to the Node.js learning documentation for the removal of module.register() and loader flags in Node.js 27.

Changes:

  • Explains migration to registerHooks() with before-and-after examples and behavioral differences.
  • Covers asynchronous alternatives, worker setup, and troubleshooting.
  • Links the guide from the Modules navigation.
File Description
site.json Adds the migration guide to the Modules navigation.
pages/​modules/​migrating-from-module-register.md Documents migration paths, examples, compatibility considerations, and common errors.

Review effort: Balanced

Document the ponyfill's cross-hook loading divergence, set an explicit
`everysync` timeout in the example and explain the default, and show the
`ERR_MODULE_REGISTER_REMOVED` error that `module.register()` now throws.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@GeoffreyBooth

Copy link
Copy Markdown
Member Author

Should this be a learn article or a blog cc @nodejs/nodejs-website

Perhaps both? This page is meant to be the durable how-to, which is why I put it in Learn: it shows how to migrate, with working examples, and it will stay useful as people upgrade over time. A blog post can announce when nodejs/node#67090 lands and point people to this article.

This branch was successfully deployed

1 active deployment
Preview — 4b2f22ce Deployed Nov 9, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants