diff --git a/lib/internal/modules/esm/resolve.js b/lib/internal/modules/esm/resolve.js index 2aa5a3df4a93bd..c0b09e51d8cc8f 100644 --- a/lib/internal/modules/esm/resolve.js +++ b/lib/internal/modules/esm/resolve.js @@ -1068,15 +1068,11 @@ function defaultResolve(specifier, context = {}) { // Avoid accessing the `protocol` property due to the lazy getters. protocol = parsed.protocol; - if (protocol === 'data:' && - parsedParentURL.protocol !== 'file:' && - experimentalNetworkImports) { - throw new ERR_NETWORK_IMPORT_DISALLOWED( - specifier, - parsedParentURL, - 'import data: from a non file: is not allowed', - ); - } + if (protocol === 'data:' && parentProtocol !== 'file:' && parentProtocol !== 'data:') { + throw new ERR_NETWORK_IMPORT_DISALLOWED( + 'import of \'data:\' is not supported: import data: from a non file: is not allowed' + ); +} if (protocol === 'data:' || (experimentalNetworkImports && (