Skip to content

Migrator.fromFileSystem fails on Windows under moduleResolution:bundler option in tsconfig.json #4297

Description

@sukazavr

What version of Effect is running?

No response

What steps can reproduce the bug?

Run packages/sql-mssql/examples/ on Windows 10

Use bundler in tsconfig.json

  "compilerOptions": {
    // ts version and module resolution (use the lasted ts/js features and types)
    "lib": ["ESNext", "dom", "dom.iterable"],
    "target": "ESNext",
    "module": "ESNext",
    "moduleDetection": "force",
    "moduleResolution": "bundler",

What is the expected behavior?

Migrations should be loaded and run successfully

What do you see instead?

ERROR (#0):
  MigrationError: Could not import migration "1_mvp"

  Error: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'd:'
      at _ (D:\Projects\CA Price\node_modules\@effect\sql\src\Migrator.ts:151:11)
      at cause (D:\Projects\CA Price\node_modules\effect\src\internal\core-effect.ts:165:18)
      at sql.transaction

Additional information

Fix is needed in packages/sql/src/Migrator/FileSystem.ts

Change the line: https://github.com/Effect-TS/effect/blob/bec5ea459a363b7893f106643b4fb61a5246f722/packages/sql/src/Migrator/FileSystem.ts#L34C25-L34C51

Instead of ${directory}/${basename} it should be file://${directory}/${basename} for Windows OS.

This primitive solution was tested on my machine. We have to make import call OS agnostic, perhaps by adding some conditions?

Activity

  1. sukazavr commented on Jan 20, 2025

    @sukazavr
    Author

    nodejs/node#31710 (comment)

    As per node.js documentation:

    The specifier of an import statement is the string after the from keyword, e.g. 'path' in import { sep } from 'path'. Specifiers are also used in export from statements, and as the argument to an import() expression.

    There are four types of specifiers:

    • Bare specifiers like 'some-package'. They refer to an entry point of a package by the package name.
    • Deep import specifiers like 'some-package/lib/shuffle.mjs'. They refer to a path within a package prefixed by the package name.
    • Relative specifiers like './startup.js' or '../config.mjs'. They refer to a path relative to the location of the importing file.
    • Absolute specifiers like 'file:///opt/nodejs/config.js'. They refer directly and explicitly to a full path.
  2. mk2s commented on Sep 11, 2025

    @mk2s

    I ran into this issue today on Win11 w/ node 22 trying to get the HTTP server example working form the "Getting Started" page. The quick-and-dirty fix to pathToFileURL(${directory}/${basename}).href in FileSystem.ts got me to a point where the HTTP server starts.

  3. abdeltif-b commented on Oct 2, 2025

    @abdeltif-b

    Any update on this? I have the same issue on Windows 11

  4. added
    3.0Used for issues, pull requests, etc. that are relevant for the `v3` branch targeting Effect v3.
    on Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.0Used for issues, pull requests, etc. that are relevant for the `v3` branch targeting Effect v3.bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions