什么是“#!/bin/env"?是什么意思(在node.js脚本的顶部)? [英] What does "#!/bin/env" mean (at the top of a node.js script)?

查看:526
本文介绍了什么是“#!/bin/env"?是什么意思(在node.js脚本的顶部)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了serval node.js项目,这些项目在其app.js的顶部(如该

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?

推荐答案

示例中的完整行是:

#!/bin/env node

这只是意味着该脚本应使用在当前PATH中找到的第一个名为"node"的可执行文件执行.

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

开头的shebang(#!)表示执行以下脚本. /bin/env是查看您当前环境的标准UNIX程序.任何非名称=值"格式的参数都是要执行的命令.有关更多详细信息,请参见您的环境手册.

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.

这篇关于什么是“#!/bin/env"?是什么意思(在node.js脚本的顶部)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆