Skip to content

vite-node fails to parse hashbang #1175

@hugo-t-b

Description

@hugo-t-b

Describe the bug

When a file has a hashbang/shebang (most often #!/usr/bin/env node), vite-node fails with this error:

Error: Parse failure: Unexpected character '!' (1:1)
Contents of line 1: #!/usr/bin/env node

Reproduction

StackBlitz link: https://stackblitz.com/edit/node-fhzvli.

System Info

System:
  OS: Linux 5.10 Ubuntu 20.04.4 LTS (Focal Fossa)
  CPU: (8) x64 Intel(R) Core(TM) i5-1035G1 CPU @ 1.00GHz
  Memory: 1.02 GB / 3.72 GB
  Container: Yes
  Shell: 5.0.17 - /bin/bash
Binaries:
  Node: 16.14.2 - ~/.nvm/versions/node/v16.14.2/bin/node
  Yarn: 1.22.15 - ~/.nvm/versions/node/v16.14.2/bin/yarn
  npm: 8.5.0 - ~/.nvm/versions/node/v16.14.2/bin/npm
npmPackages:
  vite: ^2.9.5 => 2.9.5 
  vitest: ^0.9.3 => 0.9.3

Used Package Manager

pnpm

Validations

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