What does “#!/bin/env” mean (at the top of a node.js script)?

社会主义新天地 提交于 2019-12-03 02:57:22

问题


I found serval node.js projects that have this at top of their app.js (as in this openshift program):

#!/bin/env node

What does this mean? How does this work? Where is it useful?


回答1:


The full line from your example is:

#!/bin/env node

This simply means that the script should be executed with the first executable named 'node' that's found in your current PATH.

The shebang (#!) at the start means execute the script with what follows. /bin/env is a standard unix program that looks at your current environment. Any argument to it not in a 'name=value' format is a command to execute. See your env manpage for further details.




回答2:


env is a shell command used to specify an interpreter.



来源:https://stackoverflow.com/questions/15061001/what-does-bin-env-mean-at-the-top-of-a-node-js-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!