node icon indicating copy to clipboard operation
node copied to clipboard

module: include module information in require(esm) warning

Open joyeecheung opened this issue 4 months ago • 5 comments

When emitting the experimental warning for require(esm), include information about the parent module and the module being require()-d to help users locate and update them.

For example, when using npm which relies on debug which attempts to load supports-color using require():

$ cd tools/doc
$ ../../node ../../deps/npm/bin/npm-cli.js install

npm warn cli npm v10.9.0 does not support Node.js v23.0.0-pre. This version of npm supports the following node versions: `^18.17.0 || >=20.5.0`. You can find the latest version at https://nodejs.org/.
(node:88340) ExperimentalWarning: CommonJS module /Users/joyee/projects/node/deps/npm/node_modules/debug/src/node.js is loading ES Module /Users/joyee/projects/node/deps/npm/node_modules/supports-color/index.js using require().
Support for loading ES Module in require() is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)

joyeecheung avatar Oct 15 '24 19:10 joyeecheung