Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(npm): use import to dynamically load esm modules #130

Merged
merged 1 commit into from
Feb 14, 2025

Conversation

yin1999
Copy link
Member

@yin1999 yin1999 commented Feb 13, 2025

Description

@mdn/rari cannot be installed with Node.js v22.12+, as it using require() in .js files with "type": "module" in package.json, which is currently incompatible with Node.js v22.12.0 due to stricter module handling. See: nodejs/node#56155.

Use import to dynamically load esm modules, as we have already use this in the current file:

const HttpsProxyAgent = await import("https-proxy-agent");

Motivation

I cannot successfully run yarn install in mdn/content with Node.js v22.13 installed.

Additional details

I've run npm install && npm run export-schema && npm run generate-types && npm pack in rari-npm.
And replace the @mdn/rari package in mdn/content locally, which makes the installation with Node.js v22.13 successful.

Copy link
Contributor

@fiji-flo fiji-flo left a comment

Choose a reason for hiding this comment

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

Thanks for fixing. 👍

@fiji-flo fiji-flo merged commit 9fcfe1a into mdn:main Feb 14, 2025
1 check passed
@yin1999 yin1999 deleted the node-v22.12+ branch February 14, 2025 10:39
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.

2 participants