Skip to content

Unknown file extension ".zx" #1103

@lukakostic

Description

@lukakostic

Script:

#!/usr/bin/env zx

console.log("Hi");

Ran with:
$ ./my-script.zx

Results in:

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".zx" for /data/bin/my-script.zx
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:160:9)
    at defaultGetFormat (node:internal/modules/esm/get_format:203:36)
    at defaultLoad (node:internal/modules/esm/load:143:22)
    at async ModuleLoader.load (node:internal/modules/esm/loader:409:7)
    at async ModuleLoader.moduleProvider (node:internal/modules/esm/loader:291:45)
    at async link (node:internal/modules/esm/module_job:76:21) {
  code: 'ERR_UNKNOWN_FILE_EXTENSION'
}

Why does it care about file extensions on linux?
Why cant i end my script file with .zx ?
If im running with the hashbang zx , obviously its a valid zx script (javascript) which im trying to run, so why check extension?
Its not like i can run typescript too so it needs to know js vs ts ?

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