You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So, we need to emit the current warning as is, but with the message of ERR_REQUIRE_ESM, and then redefine the message of the error to the same emmited in the warning. so new ERR_REQUIRE_ESM().message = 'same warning message emitted'
In a most short way; the warning message emitted, should be the current message concatenated with ERR_REQUIRE_ESM message, and the message of the trowned ERR_REQUIRE_ESM should the same of the emitted warning.
So at the moment we provide both a warning and an error message.
The error message should continue to be thrown, but the useful information from the warning can be folded into the error message itself.
This way it will still be shown to users, but libraries can wrap the error and swallow it if they need, whereas the warning cannot be silenced without disabling all warnings in Node.js.
(node:91392) Warning: require() of ES modules is not supported.require() of /Users/juanjose/Documents/GitHub/Node/node/mod/file2.js from /Users/juanjose/Documents/GitHub/Node/node/file.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.Instead rename file2.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/juanjose/Documents/GitHub/Node/node/mod/package.json.Must use import to load ES Module: /Users/juanjose/Documents/GitHub/Node/node/mod/file2.jsError message:Must use import to load ES Module: /Users/juanjose/Documents/GitHub/Node/node/mod/file2.jsrequire() of ES modules is not supported.require() of /Users/juanjose/Documents/GitHub/Node/node/mod/file2.js from /Users/juanjose/Documents/GitHub/Node/node/file.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.Instead rename file2.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/juanjose/Documents/GitHub/Node/node/mod/package.json.
Activity
juanarbol commentedon Nov 26, 2019
I'm gonna take this one.
guybedford commentedon Nov 27, 2019
@juanarbol that would be really great - just let me know if I can help.
juanarbol commentedon Nov 27, 2019
@guybedford sure! I'll ask you for some help if needed (I think i'll need it)
juanarbol commentedon Nov 27, 2019
So, we still needing to throws the exception, but now, the warning should contain error (
ERR_REQUIRE_ESM) message.guybedford commentedon Nov 27, 2019
@juamedgod yes the error should contain in the message the descriptive contents of what is currently in the warning.
juanarbol commentedon Nov 28, 2019
Jm, I'm misunderstanding something.
So, we need to emit the current warning as is, but with the message of
ERR_REQUIRE_ESM, and then redefine the message of the error to the same emmited in the warning. sonew ERR_REQUIRE_ESM().message = 'same warning message emitted'In a most short way; the warning message emitted, should be the current message concatenated with ERR_REQUIRE_ESM message, and the message of the trowned ERR_REQUIRE_ESM should the same of the emitted warning.
Am I right?
guybedford commentedon Nov 28, 2019
So at the moment we provide both a warning and an error message.
The error message should continue to be thrown, but the useful information from the warning can be folded into the error message itself.
This way it will still be shown to users, but libraries can wrap the error and swallow it if they need, whereas the warning cannot be silenced without disabling all warnings in Node.js.
juanarbol commentedon Nov 28, 2019
This is what I've done:
Is this the expected behaviour?
lib,test: improves ERR_REQUIRE_ESM message
lib,test: improves ERR_REQUIRE_ESM message
lib,test: improves ERR_REQUIRE_ESM message
lib,test: improves ERR_REQUIRE_ESM message