実行したいプログラムのパスがわからなくても、シバンラインを指定することはできますか?
たぶんパスを指定しないでください
#!node
またはいくつかのオプションを指定します
#!/usr/local/bin/node
#!/usr/bin/node
クロスプラットフォームソリューションの追加ポイント(Linux、BSD、OSXなどのさまざまなフレーバー...)
/usr/bin/env
クロスプラットフォーム ソリューション向けに特に考えられています。
env executes utility after modifying the environment as specified on
the command line. The option name=value specifies an environmental
variable, name, with a value of value. The option `-i' causes env
to completely ignore the environment it inherits.
If no utility is specified, env prints out the names and values of
the variables in the environment, with one name=value pair per line.
次の行の何か:
#!/usr/bin/env node
クロスプラットフォームであり、「正しい方法」です。
シバンの後にスペースを入れます。プログラムが環境変数 PATH にある場合は、移動する必要があります。
#! perl
もちろん、Perl の特殊なケースは次のようになります。
:
eval 'exec perl -S $0 ${1+"$@"}'
if 0;
これは、@Jens が指摘したように /usr/bin/env がない場合でも、UNIXおよびOSX で機能します。
シバンを使用しないでください。
node <<eof
your node program here
eof