-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
Closed
Labels
confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.esmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.moduleIssues and PRs related to the module subsystem.Issues and PRs related to the module subsystem.
Description
Details
Part of the goal of the network import feature for ECM is that I should be able to load a module hosted via any HTTPS location, like for example common CDNs for hosting such modules such as https://esm.run or https://unpkg.com.
For example, the popular uuid package claims it's an ESM:

It is hosted in the various CDNs:
Yet, none of these work when trying to load with the new network imports, see snippet.
Node.js version
17.5 with --experimental-network-imports
Example code
Example:
import { v4 as uuidv4 } from 'https://cdn.jsdelivr.net/npm/uuid@8.3.2/wrapper.mjs';
console.log(uuidv4());Output:
> node --experimental-network-imports index.js
node:internal/errors:465
ErrorCaptureStackTrace(err);
^
TypeError [ERR_INVALID_URL]: Invalid URL
at new NodeError (node:internal/errors:372:5)
at onParseError (node:internal/url:563:9)
at new URL (node:internal/url:643:5)
at ESMLoader.resolve (node:internal/modules/esm/loader:578:5)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async ESMLoader.getModuleJob (node:internal/modules/esm/loader:250:7)
at async ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:81:21)
at async Promise.all (index 0)
at async link (node:internal/modules/esm/module_job:86:9) {
input: './dist/index.js',
code: 'ERR_INVALID_URL'
}
Node.js v18.0.0-nightly20220216dace5a804e
Another example
import { v4 as uuidv4 } from 'https://unpkg.com/browse/uuid@8.3.2/wrapper.mjs'
console.log(uuidv4());Output:
> node --experimental-network-imports index.js
node:internal/errors:465
ErrorCaptureStackTrace(err);
^
RangeError [ERR_UNKNOWN_MODULE_FORMAT]: Unknown module format: null for URL https://unpkg.com/browse/uuid@8.3.2/wrapper.mjs
at new NodeError (node:internal/errors:372:5)
at ESMLoader.load (node:internal/modules/esm/loader:385:13)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async ESMLoader.moduleProvider (node:internal/modules/esm/loader:282:11) {
code: 'ERR_UNKNOWN_MODULE_FORMAT'
}
Node.js v18.0.0-nightly20220216dace5a804e
Operating system
MacOS 12.1
Scope
Runtimne
Module and version
Not applicable.
Metadata
Metadata
Assignees
Labels
confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.esmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.moduleIssues and PRs related to the module subsystem.Issues and PRs related to the module subsystem.