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
require() of ES Module ${filename}${parentPath ? ` from ${
parentPath}` : ''} not supported.
if (!packageJsonPath) {
if (StringPrototypeEndsWith(filename, '.mjs'))
msg += `\nInstead change the require of ${filename} to a dynamic ` +
'import() which is available in all CommonJS modules.';
return msg;
}
const path = require('path');
const basename = path.basename(filename) === path.basename(parentPath) ?
filename : path.basename(filename);
if (hasEsmSyntax) {
msg += `\nInstead change the require of ${basename} in ${parentPath} to` +
' a dynamic import() which is available in all CommonJS modules.';
return msg;
}
${basename} is treated as an ES module file as it is a .js
file whose nearest parent package.json contains "type": "module"
which declares all .js files in that package scope as ES modules.
Instead rename ${basename} to end in .cjs, change the requiring
code to use dynamic import() which is available in all CommonJS
modules, or change "type": "module" to "type": "commonjs" in
${packageJsonPath} to treat all .js files as CommonJS (using .mjs for
all ES modules instead).
We can detect when it's .ts or .tsx and adapt the message to explain how our rules work.
nodejs/node@e2a6399#diff-670bf55805b781d9a3579f8bca9104c04d94af87cc33220149fd7d37b095ca1cR1440-R1466
The text was updated successfully, but these errors were encountered: