Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
capitalisation fix
Link
Mark Amery
  • 158.3k
  • 93
  • 435
  • 476

Appropriate hashbang for nodeNode.js scripts

Retagged [shell] + [hashbang] as [shebang] per http://meta.stackoverflow.com/q/286617/359284
Link
Kevin Brown-Silva
  • 41.8k
  • 42
  • 207
  • 243
Source Link
Explosion Pills
  • 192.4k
  • 56
  • 341
  • 417

Appropriate hashbang for node.js scripts

I'm trying to create a script for node.js that will work in multiple environments. Particularly for me, I'm switching back and forth between OS X and Ubuntu. In the former, Node is installed as node, but in the latter it is nodejs. At the top of my script, I can have:

#!/usr/bin/env node 

or

#!/usr/bin/env nodejs 

I'd rather have the script run as an executable for either environment as long as node is installed rather than have one or the other have to specify the command (./script-name.js vs. node script-name.js).

Is there any way to specify a backup hashbang or one that is compatible in either case for node.js?