Skip to content

Commit 28e7782

Browse files
committed
update message context
1 parent baf2146 commit 28e7782

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

lib/internal/modules/cjs/loader.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -968,10 +968,10 @@ Module._extensions['.js'] = function(module, filename) {
968968
if (pkg && pkg.type === 'module') {
969969
if (warnRequireESM) {
970970
process.emitWarning(
971-
'require() of .js files inside of a package with "type": "module" ' +
972-
'in its package.json is not supported under --experimental-modules' +
973-
'\nRather use import to load this module, or if you are the author' +
974-
' you may want to use the .cjs extension for this file.'
971+
'require() of .js file ' + filename + ' is not supported as it is ' +
972+
'an ES module due to having "type": "module" in its package.json ' +
973+
'file.\nRather use import to load this module, or if you are the ' +
974+
'author you may want to use the .cjs extension for this file.'
975975
);
976976
warnRequireESM = false;
977977
}

test/es-module/test-cjs-esm-warn.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ child.on('close', common.mustCall((code, signal) => {
1717
assert.strictEqual(code, 0);
1818
assert.strictEqual(signal, null);
1919
assert.strictEqual(stderr, `(node:${child.pid}) Warning: require() of .js ` +
20-
'files inside of a package with "type": "module" in its package.json ' +
21-
'is not supported under --experimental-modules\nRather use import to ' +
22-
'load this module, or if you are the author you may want to use the ' +
23-
'.cjs extension for this file.\n');
20+
`file ${entry} is not supported as it is an ES module due to having ` +
21+
'"type": "module" in its package.json file.\nRather use import to load ' +
22+
'this module, or if you are the author you may want to use the .cjs ' +
23+
'extension for this file.\n');
2424
}));

0 commit comments

Comments
 (0)