data-import-fix

0.0.1 • Public • Published

data-import-fix

This is a workaround for node.js issue #51956 where data URLs cannot load modules from the disk, throwing either TypeError: Invalid URL or ERR_UNSUPPORTED_RESOLVE_REQUEST: Invalid relative URL or base scheme is not hierarchical.

Effectively, this module allows you to import stuff from node_modules in a data URL.

This works by tracking what folder each base64 URL is spawned from, then resolving its external modules from that path on disk.

This uses the new register hooks API introduced as stable in node 20+. This package therefore requires node 20+.

Usage:

Install data-import-fix to your package.json, reinstall with npm/yarn/pnpm.

Run your program with

node --import data-import-fix [node args] <my script>

Data URLs should now be able to import from the disk.

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i data-import-fix

      Weekly Downloads

      1

      Version

      0.0.1

      License

      GPL-2.0-only

      Unpacked Size

      4.27 kB

      Total Files

      5

      Last publish

      Collaborators

      • xenxier