Skip to content

bug: npm test fails on Windows - Jest invoked via bash shim #129

@AdityaChauhanX07

Description

@AdityaChauhanX07

Problem

npm test fails immediately on Windows with a SyntaxError:

> node --experimental-vm-modules node_modules/.bin/jest --coverage --coverageReporters=text-summary

F:\PROJECTS\GSoC\accord\template-engine\node_modules\.bin\jest:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
          ^^^^^^^

SyntaxError: missing ) after argument list

What's happening

The test script in package.json runs node node_modules/.bin/jest. On Linux/macOS this works because .bin/jest is a symlink to the actual JS file. On Windows, .bin/jest is a bash shell shim, so Node tries to parse it as JavaScript and crashes.

The coverage script has the same problem.

Build and lint work fine, only test/coverage are broken.

Fix

Replace node_modules/.bin/jest with node_modules/jest-cli/bin/jest.js. That's the actual JS entry point and works on all platforms. The --experimental-vm-modules flag stays the same.

I'll submit a PR for this.

Environment

  • Windows 11
  • Node v22.16.0
  • template-engine v2.7.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions