Skip to content

Windows: detect command fails with doubled drive letter in path #95

@SallyRS

Description

@SallyRS

Bug

npx impeccable detect <url> fails on Windows with:

Error: Browser script not found at C:\C:\Users\...\detect-antipatterns-browser.js

Note the doubled C:\C:\.

Cause

In src/detect-antipatterns.mjs, two locations construct the path to detect-antipatterns-browser.js using:

path.dirname(new URL(import.meta.url).pathname)

On Windows, new URL('file:///C:/foo/bar').pathname returns /C:/foo/bar (with a leading slash). When passed to path.join or path.resolve, Node prepends the drive letter again, producing C:\C:\....

Affected lines:

  • ~L2690: path.dirname(new URL(import.meta.url).pathname) (puppeteer scan path)
  • ~L3506: path.dirname(new URL(import.meta.url).pathname) (live detect path)

Fix

Replace new URL(import.meta.url).pathname with fileURLToPath(import.meta.url) from node:url, which correctly handles Windows drive letters:

import { fileURLToPath } from 'node:url';
const scriptPath = path.join(path.dirname(fileURLToPath(import.meta.url)), 'detect-antipatterns-browser.js');

Environment

  • Windows 11 Pro
  • Node.js (via npm global install)
  • impeccable installed via npm i -g impeccable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions