Skip to content

fix(config): ERR_UNSUPPORTED_ESM_URL_SCHEME when loading JS config file on Windows #327

@alexvy86

Description

@alexvy86

Syncpack version

14.0.2

Operating system(s)

Windows

Steps to reproduce

  1. Create a repo with a syncpack.config.cjs config file.
  2. Run npx syncpack lint
Image

package.json

{
	"name": "syncpack-windows-repro",
	"version": "1.0.0",
	"private": true,
	"scripts": {
		"syncpack": "syncpack lint"
	}
}

syncpack.config.cjs

module.exports = {
	semverGroups: [
		{
			label: "Dependencies should use caret dependency ranges",
			dependencies: ["**"],
			dependencyTypes: ["dev", "peer", "prod"],
			packages: ["**"],
			range: "^",
		},
	],
};

Expected behavior

syncpack reads the config and runs normally.

Actual behavior

Node.js throws when trying to import() a file, I imagine the .cjs config file

  Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: 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 'c:'
      at throwIfUnsupportedURLScheme (node:internal/modules/esm/load:241:11)
      at defaultLoad (node:internal/modules/esm/load:132:3)
      at ModuleLoader.load (node:internal/modules/esm/loader:724:12)
      at ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:543:56)
      at #createModuleJob (node:internal/modules/esm/loader:567:36)
      at #getJobFromResolveResult (node:internal/modules/esm/loader:297:34)
      at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:265:41)
      at async ModuleLoader.import (node:internal/modules/esm/loader:605:23)

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions