最佳答案
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?