How to make a shell executable node file using TypeScript

前端 未结 7 2007
日久生厌
日久生厌 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:42

    If you have TypeScript and ts-node installed globally:

    npm install typescript ts-node -g
    

    You can now easily do this with:

    #!/usr/bin/env ts-node
    
    console.log('Hello world')
    

提交回复
热议问题