diff --git a/lib/internal/errors.js b/lib/internal/errors.js index e84b9f6c851205..a8c2a9ea15db04 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -1450,7 +1450,7 @@ E('ERR_MISSING_ARGS', E('ERR_MISSING_OPTION', '%s is required', TypeError); E('ERR_MODULE_NOT_FOUND', function(path, base, exactUrl) { if (exactUrl) { - lazyInternalUtil().setOwnProperty(this, 'url', exactUrl); + lazyInternalUtil().setOwnProperty(this, 'url', `${exactUrl}`); } return `Cannot find ${ exactUrl ? 'module' : 'package'} '${path}' imported from ${base}`; diff --git a/test/es-module/test-esm-import-meta-resolve.mjs b/test/es-module/test-esm-import-meta-resolve.mjs index 8495c161312822..a6435655750c88 100644 --- a/test/es-module/test-esm-import-meta-resolve.mjs +++ b/test/es-module/test-esm-import-meta-resolve.mjs @@ -9,10 +9,8 @@ const fixtures = dirname.slice(0, dirname.lastIndexOf('/', dirname.length - 2) + assert.strictEqual(import.meta.resolve('./test-esm-import-meta.mjs'), dirname + 'test-esm-import-meta.mjs'); -const notFound = import.meta.resolve('./notfound.mjs'); -assert.strictEqual(new URL(notFound).href, new URL('./notfound.mjs', import.meta.url).href); -const noExtension = import.meta.resolve('./asset'); -assert.strictEqual(new URL(noExtension).href, new URL('./asset', import.meta.url).href); +assert.strictEqual(import.meta.resolve('./notfound.mjs'), new URL('./notfound.mjs', import.meta.url).href); +assert.strictEqual(import.meta.resolve('./asset'), new URL('./asset', import.meta.url).href); try { import.meta.resolve('does-not-exist'); assert.fail();