How to make a shell executable node file using TypeScript

前端 未结 7 1907
日久生厌
日久生厌 2021-02-05 05:56

Normally in node files I just put

#!/usr/bin/env node 

at the top and make it executable to create a file that can be run from a bash terminal.

7条回答
  •  离开以前
    2021-02-05 06:52

    See https://github.com/Microsoft/TypeScript/blob/master/bin/tsc for an example. Basically have a dummy file without the .js extension and just require the actual .js file.

    E.g. In file named tsc:

    #!/usr/bin/env node
    require('./tsc.js')
    

提交回复
热议问题